Skip to content

Commit d6f56f5

Browse files
committed
Add mfio-netfs example
1 parent 2fc6398 commit d6f56f5

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

mfio-netfs/examples/net_sample.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use mfio::backend::*;
2+
use mfio::error::Result;
3+
use mfio::traits::*;
4+
use mfio_netfs::NetworkFs;
5+
use mfio_rt::*;
6+
7+
fn main() -> Result<()> {
8+
let rt = NativeRt::default();
9+
let rt = NetworkFs::with_fs("127.0.0.1:4446".parse().unwrap(), rt.into(), true)?;
10+
11+
rt.block_on(async {
12+
let file = rt
13+
.open(Path::new("Cargo.toml"), OpenOptions::new().read(true))
14+
.await?;
15+
16+
let mut buf = vec![];
17+
file.read_to_end(0, &mut buf).await?;
18+
19+
let data = String::from_utf8_lossy(&buf);
20+
println!("{data}");
21+
22+
Ok(())
23+
})
24+
}

0 commit comments

Comments
 (0)