Function read_to_string
async fn read_to_string<impl AsRef<Path>: AsRef<std::path::Path>>(path: impl AsRef<Path>) -> Result<String>
Creates a future which will open a file for reading and read the entire contents into a string and return said string.
This is the async equivalent of std::fs::read_to_string.
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<()> {
let contents = fs::read_to_string("foo.txt").await?;
println!("foo.txt contains {} bytes", contents.len());
# Ok(())
# }