Skip to main content

Preprocessor

Trait Preprocessor 

Source
pub trait Preprocessor: Send + Sync {
    // Required methods
    fn fork(&self) -> Box<dyn Preprocessor>;
    fn splitter(&self) -> Option<Box<dyn Splitter>>;

    // Provided methods
    fn process(&mut self, data: &[u8]) -> (Vec<u8>, Vec<ParseError>) { ... }
    fn process_with_metadata(
        &mut self,
        data: &[u8],
        _metadata: Option<&ConnectorMetadata>,
    ) -> (Vec<u8>, Vec<ParseError>) { ... }
}
Expand description

Trait for preprocessing raw data before parsing.

Required Methods§

Source

fn fork(&self) -> Box<dyn Preprocessor>

Create a new preprocessor with the same configuration as self.

Used by multithreaded transport endpoints to create multiple parallel input pipelines.

Source

fn splitter(&self) -> Option<Box<dyn Splitter>>

Returns an object that can be used to break a stream of incoming data into complete records to pass to Preprocessor::process. If the object is None, the parser’s splitter object will actually be used.

Provided Methods§

Source

fn process(&mut self, data: &[u8]) -> (Vec<u8>, Vec<ParseError>)

Process raw input data and return transformed data.

The default implementation forwards to process_with_metadata with no metadata.

§Arguments
  • data - Raw input data bytes
§Returns

The transformed data and any errors that occurred.

Source

fn process_with_metadata( &mut self, data: &[u8], _metadata: Option<&ConnectorMetadata>, ) -> (Vec<u8>, Vec<ParseError>)

Process raw input data and return transformed data using connector metadata.

Users should implement exactly one of the two processing methods: process or process_with_metadata.

WARNING: a preprocessor that implements neither processing method compiles, but will panic at runtime with a stack overflow.

§Arguments
  • data - Raw input data bytes
  • _metadata - Connector metadata
§Returns

The transformed data and any errors that occurred.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§