3 unstable releases
0.2.1 | Jan 19, 2024 |
---|---|
0.2.0 | Jan 19, 2024 |
0.1.0 | Jan 19, 2024 |
#1050 in Asynchronous
7KB
99 lines
Delimiter Stream
A simple stream type for pulling out a delimited chunk of data, while preserving any excess data read in a buffer.
lib.rs
:
Stream type for splitting a delimited stream
const TEST: &[u8] = b"FOOBARFOOBARBAZFOO";
const DELIM: &[u8] = b"BAZ";
let stream = ReaderStream::new(TEST);
let mut slice_stream = DelimiterSlice::new(stream, DELIM);
let data = slice_stream.next().await.unwrap().unwrap();
assert_eq!(&data, &TEST[0..12]);
let data = slice_stream.next().await.unwrap().unwrap();
assert_eq!(&data, &TEST[15..]);
Dependencies
~0.7–0.9MB
~16K SLoC