mirror of
https://github.com/guilhermewerner/mini-redis
synced 2025-06-18 16:05:02 +00:00
Implement Some Tokio Tutorials
This commit is contained in:
17
Tutorial/ReadFile.rs
Normal file
17
Tutorial/ReadFile.rs
Normal file
@ -0,0 +1,17 @@
|
||||
#![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(())
|
||||
}
|
Reference in New Issue
Block a user