Trait nom::Producer [] [src]

pub trait Producer<'b, I, M: 'b> {
    fn apply<'a, O, E>(&'b mut self, consumer: &'a mut Consumer<I, O, E, M>) -> &'a ConsumerState<O, E, M>;

    fn run<'a, O, E: 'b>(&'b mut self, consumer: &'a mut Consumer<I, O, E, M>) -> Option<&O> { ... }
}

The producer wraps a data source, like file or network, and applies a consumer on it

it handles buffer copying and reallocation, to provide streaming patterns. it depends on the input type I, and the message type M. the consumer can change the way data is produced (for example, to seek in the source) by sending a message of type M.

Required Methods

fn apply<'a, O, E>(&'b mut self, consumer: &'a mut Consumer<I, O, E, M>) -> &'a ConsumerState<O, E, M>

Applies a consumer once on the produced data, and return the consumer's state

a new producer has to implement this method

Provided Methods

fn run<'a, O, E: 'b>(&'b mut self, consumer: &'a mut Consumer<I, O, E, M>) -> Option<&O>

Applies a consumer once on the produced data, and returns the generated value if there is one

Implementors