Hello, I'd like to purpose BufReadSplitter. A library to split (separate) a stream into sub-subtreams according to a defined pattern (an array of [u8] or other).
An example of usage :
use std::io::Read;
use buf_read_splitter::{BufReadSplitter,MatchResult,Options,SimpleMatcher};
let mut input_reader = .....
// Create a reader that will be separated by "<SEP>"
let mut reader = BufReadSplitter::new(
&mut input_reader,
SimpleMatcher::new(b"----------separator"),
Options::default()
.set_limit_read(Some(1_024)), // 1ko max to avoid memory overload
.clone()
);
while reader.next().unwrap() {
let mut content = Vec::new();
let _ = reader.read_to_end(&mut content);
// Treat content ...
}
I'm proud of this little tool (well... the algorithm design was more complicated than excepted
) It has reached the stable state of version 1.0.0 ! Hope my efforts can be useful for others !! MIT license.