buf_read_splitter 0.4.0

A stream reader with ability to read a stream until a defined pattern is reached (usually an array of [u8])
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use crate::MatchResult;

pub trait Matcher {
    ///
    /// Called for each byte, return the state of the match
    fn sequel(&mut self, el_buf: u8, pos: usize) -> MatchResult;
    ///
    /// Called at the end of the stream, only if the previous byte (and so last byte) is in a NeedNext state.
    /// This function is useful for specific case.
    /// Note: `pos` is the position of the last readed byte (so the same as the previous one)
    fn sequel_eos(&mut self, _pos: usize) -> MatchResult {
        MatchResult::Mismatch
    }
}