Closed MarkBiesheuvel closed 1 year ago
First try failed.
At the moment the ClientBuilder
is the owner of the content
variable. If the ClientBuilder
goes out of scope. So do all references.
Idea: implement a similar function signature to std::io::Read::read_to_string
.
let mut buffer = String::new();
let client = ClientBuilder::new()
.with_local_datafile(FILE_PATH, buffer)?
.build()?;
Now, buffer
will remain in scope, so client
is allowed to have references to it.
Second attempt failed.
The challenge is the keep the datafile::Json
variable in scope, while also passing it (as mutable reference) to many different constructors.
At the moment, there is no reason to optimize memory management of parsing the datafile. Using owned String values is fine for now.
And reduce the number of
.to_owned()
calls