# tokio::fs::read_to_string - Rust
API documentation for the Rust `read_to_string` fn in crate `tokio`.
Keywords: rust, rustlang, rust-lang, read_to_string

# Function tokio::fs::read_to_string [−] [src]

    pub async fn read_to_string(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`.

# Examples

    use tokio::fs;

    let contents = fs::read_to_string("foo.txt").await?;
    println!("foo.txt contains {} bytes", contents.len());