mirror of
https://github.com/guilhermewerner/mini-redis
synced 2025-06-16 23:15:06 +00:00
Implement Some Tokio Tutorials
This commit is contained in:
17
Tutorial/ReadPart.rs
Normal file
17
Tutorial/ReadPart.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 = [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(())
|
||||
}
|
Reference in New Issue
Block a user