Implement Some Tokio Tutorials

This commit is contained in:
GuilhermeWerner
2021-01-19 16:03:55 -03:00
parent 2e7b35e32d
commit 055be51002
12 changed files with 415 additions and 0 deletions

17
Tutorial/ReadPart.rs Normal file
View 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 = [1; 10];
let mut file = File::open("README.md").await?;
// read up to 10 bytes
let n = file.read(&mut buffer[..]).await?;
println!("The bytes: {:?}", &buffer[..n]);
Ok(())
}