I could create a separate thread to act as an I/O queue, but I'm not sure whether this is the best way. It looks like the best.
I do not know how to load a local file with mio.
Use tokio::fs::read:
use tokio::prelude::Future;
fn main() {
let task = tokio::fs::read("/proc/cpuinfo").map(|data| {
// do something with the contents of the file ...
println!("contains {} bytes", data.len());
println!("{:?}", String::from_utf8(data));
}).map_err(|e| {
// handle errors
eprintln!("IO error: {:?}", e);
});
tokio::run(task);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With