[−][src]Trait nom::Producer
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 dyn Consumer<I, O, E, M>
) -> &'a ConsumerState<O, E, M>
&'b mut self,
consumer: &'a mut dyn 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.
WARNING: if the ConsumerState generated by your consumer has a reference
to the input, it will generate borrow checking errors such as
error: cannot borrowproduceras mutable more than once at a time [E0499].
It is caused by the producer's ability to refill the input at will, so it can modify
the input slice the ConsumerState is referring to.
To avoid that kind of issue, try to do all the computations on input slices inside the
Consumer chain
Provided Methods
fn run<'a: 'b, O, E: 'b>(
&'b mut self,
consumer: &'a mut dyn Consumer<I, O, E, M>
) -> Option<&O>
&'b mut self,
consumer: &'a mut dyn 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
impl<'b, I: Copy, M: 'b> Producer<'b, I, M> for ProducerRepeat<I>[src]
impl<'b, I: Copy, M: 'b> Producer<'b, I, M> for ProducerRepeat<I>fn apply<'a, O, E>(
&'b mut self,
consumer: &'a mut dyn Consumer<I, O, E, M>
) -> &'a ConsumerState<O, E, M>[src]
fn apply<'a, O, E>(
&'b mut self,
consumer: &'a mut dyn Consumer<I, O, E, M>
) -> &'a ConsumerState<O, E, M>fn run<'a: 'b, O, E: 'b>(
&'b mut self,
consumer: &'a mut dyn Consumer<I, O, E, M>
) -> Option<&O>[src]
fn run<'a: 'b, O, E: 'b>(
&'b mut self,
consumer: &'a mut dyn Consumer<I, O, E, M>
) -> Option<&O>impl<'x> Producer<'x, &'x [u8], Move> for FileProducer[src]
impl<'x> Producer<'x, &'x [u8], Move> for FileProducerfn apply<'a, O, E>(
&'x mut self,
consumer: &'a mut dyn Consumer<&'x [u8], O, E, Move>
) -> &'a ConsumerState<O, E, Move>[src]
fn apply<'a, O, E>(
&'x mut self,
consumer: &'a mut dyn Consumer<&'x [u8], O, E, Move>
) -> &'a ConsumerState<O, E, Move>fn run<'a: 'b, O, E: 'b>(
&'b mut self,
consumer: &'a mut dyn Consumer<I, O, E, M>
) -> Option<&O>[src]
fn run<'a: 'b, O, E: 'b>(
&'b mut self,
consumer: &'a mut dyn Consumer<I, O, E, M>
) -> Option<&O>impl<'x, 'b> Producer<'b, &'x [u8], Move> for MemProducer<'x>[src]
impl<'x, 'b> Producer<'b, &'x [u8], Move> for MemProducer<'x>