Skip to main content

Decoder

Trait Decoder 

Source
pub trait Decoder: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn decode_chunk_into(&self, chunk: &Chunk, sink: &mut dyn DecodeOutputSink);

    // Provided methods
    fn version(&self) -> &'static str { ... }
    fn admission_sketch(&self, _chunk: &Chunk) -> DecodeAdmissionSketch { ... }
    fn admission(&self, _chunk: &Chunk) -> DecodeAdmission { ... }
    fn decode_chunk(
        &self,
        chunk: &Chunk,
    ) -> Result<Vec<Chunk>, DecodeCollectionError> { ... }
}
Expand description

A trait for decoding chunks to find hidden secrets.

Required Methods§

Source

fn name(&self) -> &'static str

Source

fn decode_chunk_into(&self, chunk: &Chunk, sink: &mut dyn DecodeOutputSink)

Produce decoded chunks into a caller-owned bounded sink.

This is the required production method. Implementations must stop candidate production immediately after sink.push returns false; materializing an intermediate unbounded collection is forbidden.

Provided Methods§

Source

fn version(&self) -> &'static str

Stable implementation version used by compiled scanner and autoroute identity. Increment this value whenever the decoder can emit a different set of chunks for the same input.

Source

fn admission_sketch(&self, _chunk: &Chunk) -> DecodeAdmissionSketch

Bounded work projection for this decoder on chunk.

Custom decoders default to an unknown, conservative sketch. Built-in decoders override this beside their streaming grammar.

Source

fn admission(&self, _chunk: &Chunk) -> DecodeAdmission

Whether this decoder can produce output for chunk.

Custom decoders default to DecodeAdmission::Unknown, which always fails open. Built-in decoders derive this from the sketch owned next to their streaming grammar. Only Impossible permits the engine to skip decode post-processing.

Source

fn decode_chunk( &self, chunk: &Chunk, ) -> Result<Vec<Chunk>, DecodeCollectionError>

Collect decoded chunks through the same count/byte limits as production.

This compatibility helper is fallible rather than silently truncating or materializing attacker-controlled output without a bound.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§