stream_inmemory/
lib.rs

1//! Simple inmemory stream.
2//!
3//! Created for use as a buffer. Supports write, peek, read, skip operations.
4//!
5//! # Examples
6//!
7//! ### Write, read stream.
8//! ```
9//! use stream_inmemory::{Stream, TWrite, TRead};
10//! let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
11//! let mut stream = Stream::new();
12//! stream.write(&arr[2..6]);
13//! assert_eq!(stream.available(), 4);
14//! let mut dest = [0; 10];
15//! stream.read(&mut dest);
16//! stream.truncate_readied();
17//! assert_eq!(dest, [3, 4, 5, 6, 0, 0, 0, 0, 0, 0]);
18//! assert_eq!(stream.available(), 0);
19//! ```
20//!
21
22mod traits;
23mod stream;
24
25#[cfg(test)]
26mod tests;
27
28pub use stream::{Stream, StreamError};
29pub use traits::{TRead, TWrite};