A small helper library to convert a flume
channel of Bytes
into a Channel{Reader,Writer}
that implements {Read,Write}
.
```rust use std::io::Read;
use bytes::Bytes; use channel_reader::ChannelReader; use flume::bounded;
fn main() { let (tx, rx) = bounded(10); let senderthread = std::thread::spawn(move || { for i in 0..10 { let buffer = Bytes::from(vec![i; 10]); tx.send(buffer).unwrap(); } }); senderthread.join().unwrap();
let mut reader = ChannelReader::new(rx);
let mut buffer = vec![];
reader.read_to_end(&mut buffer).unwrap();
assert_eq!(buffer.len(), 100);
} ```
The goal is to bridge an async reader-like-thing (in this case a DmaStreamReader in Glommio) into a synchronous reader.
I like the API, and in theory as chunks are dropped on the sync side of the sender depending on how the caller is doing things the memory can be reused.