4 releases (2 breaking)
0.3.1 | Jun 14, 2021 |
---|---|
0.3.0 | Jun 14, 2021 |
0.2.0 | Jun 14, 2021 |
0.1.1 |
|
0.1.0 | May 19, 2021 |
#66 in #in-memory
9KB
154 lines
Simple inmemory stream.
Created for use as a buffer. Supports write, peek, read, skip operations.
Examples
Write, read stream.
use stream_inmemory::{Stream, TWrite, TRead};
let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
let mut stream = Stream::new();
stream.write(&arr[2..6]);
assert_eq!(stream.available(), 4);
let mut dest = [0; 10];
stream.read(&mut dest);
stream.truncate_readied();
assert_eq!(dest, [3, 4, 5, 6, 0, 0, 0, 0, 0, 0]);
assert_eq!(stream.available(), 0);