Function write

async fn write<impl AsRef<Path>: AsRef<std::path::Path>, impl AsRef<[u8]>: AsRef<[u8]>>(path: impl AsRef<Path>, contents: impl AsRef<[u8]>) -> Result<()>

Creates a future that will open a file for writing and write the entire contents of contents to it.

This is the async equivalent of std::fs::write.

This operation is implemented by running the equivalent blocking operation on a separate thread pool using spawn_blocking.

Examples

use tokio::fs;

# async fn dox() -> std::io::Result<()> {
fs::write("foo.txt", b"Hello world!").await?;
# Ok(())
# }