pub trait In<TIn, TCollected>where
TIn: Send,{
// Required methods
fn run(&mut self, input: TIn);
fn finalize(self) -> Option<TCollected>;
// Provided method
fn is_ordered(&self) -> bool { ... }
}Expand description
Trait defining a node that receive data.
§Examples:
A node that increment an internal counter each time an input is received and return the total count of input received:
use ppl::prelude::*;
struct Sink {
counter: usize,
}
impl In<u64, usize> for Sink {
fn run(&mut self, input: u64) {
println!("{}", input);
self.counter = self.counter + 1;
}
fn finalize(self) -> Option<usize> {
println!("End");
Some(self.counter)
}
}Required Methods§
Provided Methods§
Sourcefn is_ordered(&self) -> bool
fn is_ordered(&self) -> bool
This method return a boolean that represent if the node must receive the input respecting the order of arrival. Override this method allow choosing if the node must preserve the order of the input.