Files
mini-redis/Tutorial/ReadFile.rs
2021-01-19 16:03:55 -03:00

18 lines
348 B
Rust

#![allow(non_snake_case)]
use tokio::fs::File;
use tokio::io::{self, AsyncReadExt};
#[tokio::main]
async fn main() -> io::Result<()> {
let mut buffer = Vec::new();
let mut file = File::open("README.md").await?;
// read the whole file
file.read_to_end(&mut buffer).await?;
println!("The bytes: {:?}", &buffer);
Ok(())
}