Skip to main content

Splitter

Trait Splitter 

Source
pub trait Splitter: Send + Sync {
    // Required methods
    fn input(&mut self, data: &[u8]) -> Option<usize>;
    fn clear(&mut self);
}
Expand description

Splits a data stream at boundaries between records.

Parser::parse or Preprocessor::process can only parse complete records. For a byte stream source, a format-specific Splitter allows a transport to find boundaries.

Required Methods§

Source

fn input(&mut self, data: &[u8]) -> Option<usize>

Looks for a record boundary in data. Returns:

  • None, if data does not necessarily complete a record.

  • Some(n), if the first n bytes of data, plus any data previously presented for which None was returned, form one or more complete records. If n < data.len(), then the caller should re-present data[n..] for further splitting.

Source

fn clear(&mut self)

Clears any state in this splitter and prepares it to start splitting new data.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§