Skip to content

Commit

Permalink
Add mfio-netfs example
Browse files Browse the repository at this point in the history
  • Loading branch information
h33p committed Dec 7, 2023
1 parent 2fc6398 commit d6f56f5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions mfio-netfs/examples/net_sample.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use mfio::backend::*;
use mfio::error::Result;
use mfio::traits::*;
use mfio_netfs::NetworkFs;
use mfio_rt::*;

fn main() -> Result<()> {
let rt = NativeRt::default();
let rt = NetworkFs::with_fs("127.0.0.1:4446".parse().unwrap(), rt.into(), true)?;

rt.block_on(async {
let file = rt
.open(Path::new("Cargo.toml"), OpenOptions::new().read(true))
.await?;

let mut buf = vec![];
file.read_to_end(0, &mut buf).await?;

let data = String::from_utf8_lossy(&buf);
println!("{data}");

Ok(())
})
}

0 comments on commit d6f56f5

Please sign in to comment.