1 use crate::fs::asyncify;
2 
3 use std::{io, path::Path};
4 
5 /// Creates a future which will open a file for reading and read the entire
6 /// contents into a string and return said string.
7 ///
8 /// This is the async equivalent of `std::fs::read_to_string`.
9 ///
10 /// # Examples
11 ///
12 /// ```no_run
13 /// use tokio::fs;
14 ///
15 /// # async fn dox() -> std::io::Result<()> {
16 /// let contents = fs::read_to_string("foo.txt").await?;
17 /// println!("foo.txt contains {} bytes", contents.len());
18 /// # Ok(())
19 /// # }
20 /// ```
read_to_string(path: impl AsRef<Path>) -> io::Result<String>21 pub async fn read_to_string(path: impl AsRef<Path>) -> io::Result<String> {
22     let path = path.as_ref().to_owned();
23     asyncify(move || std::fs::read_to_string(path)).await
24 }
25