Transcoder

Trait Transcoder 

Source
pub trait Transcoder: Send {
    type Input: Send + 'static;
    type Output: Send + 'static;

    // Required method
    fn transcode(&mut self, item: &Self::Input) -> Vec<Self::Output>;

    // Provided methods
    fn prologue(&mut self) -> Vec<Self::Output> { ... }
    fn epilogue(&mut self) -> Vec<Self::Output> { ... }
}
Expand description

Stream transcoder: maps an input stream to an output stream.

Stateful, supports 1:N mapping and stream lifecycle hooks. Used for both directions (recv and send) of a protocol endpoint.

Required Associated Types§

Source

type Input: Send + 'static

Input item type consumed by this transcoder.

Source

type Output: Send + 'static

Output item type produced by this transcoder.

Required Methods§

Source

fn transcode(&mut self, item: &Self::Input) -> Vec<Self::Output>

Map one input item to zero or more output items.

Provided Methods§

Source

fn prologue(&mut self) -> Vec<Self::Output>

Events emitted before the input stream starts.

Source

fn epilogue(&mut self) -> Vec<Self::Output>

Events emitted after the input stream ends.

Implementors§

Source§

impl<T: Clone + Send + 'static> Transcoder for Identity<T>

Source§

type Input = T

Source§

type Output = T