pub async fn write_to_file(
target_path: impl AsRef<Path>,
serialized_json: &str,
) -> Result<(), Error>
Expand description
Writes serialized JSON content to a file asynchronously.
§Arguments
target_path
- A reference to the path where the file will be written.serialized_json
- The JSON content as a string to write to the file.
§Returns
Result<(), io::Error>
-Ok(())
if the write succeeds, or anio::Error
otherwise.
§Errors
- Returns an
io::Error
if file creation, writing, or flushing fails.