Function write
pub async fn write(
path: impl AsRef<Path>,
contents: impl AsRef<[u8]>,
) -> Result<()>
Available on crate feature
fs only.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;
fs::write("foo.txt", b"Hello world!").await?;
MIT License
Copyright © Tokio Contributors
https://docs.rs/tokio/1.53.1/tokio/fs/fn.write.html