1 个不稳定版本
使用旧的 Rust 2015
0.0.5 | 2019年6月7日 |
---|
#49 in #fs-file
1,466 每月下载量
在 17 个crates (6 直接) 中使用
18KB
387 行
fs
重新发布自 [futures-fs](https://github.com/seanmonstar/futures-fs)
,通过 Future
和 Stream
在线程外访问文件系统操作。
用法
let fs = FsPool::default();
// our source file
let read = fs.read("/home/sean/foo.txt", Default::default());
// default writes options to create a new file
let write = fs.write("/home/sean/out.txt", Default::default());
// block this thread!
// the reading and writing however will happen off-thread
read.forward(write).wait()
.expect("IO error piping foo.txt to out.txt");
lib.rs
:
一个线程池来处理文件I/O操作。
示例
extern crate futures;
extern crate futures_fs;
use futures::{Future, Stream};
use futures_fs::FsPool;
let fs = FsPool::default();
// our source file
let read = fs.read("/home/sean/foo.txt", Default::default());
// default writes options to create a new file
let write = fs.write("/home/sean/out.txt", Default::default());
// block this thread!
// the reading and writing however will happen off-thread
read.forward(write).wait()
.expect("IO error piping foo.txt to out.txt");
依赖项
~490KB