Trait ppl::pipeline::node::InOut

source ·
pub trait InOut<TIn, TOut>: DynClone {
    // Required method
    fn run(&mut self, input: TIn) -> Option<TOut>;

    // Provided methods
    fn produce(&mut self) -> Option<TOut> { ... }
    fn number_of_replicas(&self) -> usize { ... }
    fn is_ordered(&self) -> bool { ... }
    fn is_producer(&self) -> bool { ... }
}
Expand description

Trait defining a node that receive an input and produce an output.

§Examples:

A node that receive an integer and increment it by one:

use ppl::prelude::*;
#[derive(Clone)]
struct Worker {}
impl InOut<i32, i32> for Worker {
   fn run(&mut self, input: i32) -> Option<i32> {
       Some(input + 1)
   }
}

Required Methods§

source

fn run(&mut self, input: TIn) -> Option<TOut>

This method is called each time the node receive an input.

Provided Methods§

source

fn produce(&mut self) -> Option<TOut>

If is_producer is true then this method will be called by the rts immediately after the execution of run. This method is called by the rts until a None is returned. When None is returned, the node will return to wait for another input. This method can be useful when we have a node that produce multiple outputs for each input it receive.

source

fn number_of_replicas(&self) -> usize

This method return the number of replicas of the node. Override this method allow to choose the number of replicas of the node.

source

fn is_ordered(&self) -> bool

This method return a boolean that represent if the node produce the output in an ordered way or not. Override this method allow choosing if the node must produce the output preserving the order of the input.

source

fn is_producer(&self) -> bool

This method return a boolean that represent if the node is a producer or not. Override this method allow choosing if the node produce multiple output for each input received, or not.

Implementors§

source§

impl<T> InOut<Vec<T>, Vec<T>> for OrderedSplitter<T>
where T: Send + 'static + Clone,

source§

impl<T> InOut<Vec<T>, Vec<T>> for Splitter<T>
where T: Send + 'static + Clone,

source§

impl<T> InOut<T, Vec<T>> for Aggregator<T>
where T: Send + 'static + Clone,

source§

impl<T> InOut<T, Vec<T>> for OrderedAggregator<T>
where T: Send + 'static + Clone,

source§

impl<T, F> InOut<T, T> for Filter<T, F>
where T: Send + 'static + Clone, F: FnMut(&T) -> bool + Send + 'static + Clone,

source§

impl<T, F> InOut<T, T> for OrderedFilter<T, F>
where T: Send + 'static + Clone, F: FnMut(&T) -> bool + Send + 'static + Clone,

source§

impl<T, U, F> InOut<T, U> for OrderedParallel<T, U, F>
where T: Send + 'static + Clone, U: Send + 'static + Clone, F: FnMut(T) -> U + Send + 'static + Clone,

source§

impl<T, U, F> InOut<T, U> for OrderedSequential<T, U, F>
where T: Send + 'static + Clone, U: Send + 'static + Clone, F: FnMut(T) -> U + Send + 'static + Clone,

source§

impl<T, U, F> InOut<T, U> for Parallel<T, U, F>
where T: Send + 'static + Clone, U: Send + 'static + Clone, F: FnMut(T) -> U + Send + 'static + Clone,

source§

impl<T, U, F> InOut<T, U> for Sequential<T, U, F>
where T: Send + 'static + Clone, U: Send + 'static + Clone, F: FnMut(T) -> U + Send + 'static + Clone,

source§

impl<TIn, TInIter, F> InOut<TInIter, TIn> for OrderedReduce<TIn, F>
where TIn: Send + Clone + 'static, TInIter: IntoIterator<Item = TIn>, F: FnOnce(TIn, TIn) -> TIn + Send + Copy + Sync,

source§

impl<TIn, TInIter, F> InOut<TInIter, TIn> for Reduce<TIn, F>
where TIn: Send + Clone + 'static, TInIter: IntoIterator<Item = TIn>, F: FnOnce(TIn, TIn) -> TIn + Send + Copy + Sync,

source§

impl<TIn, TInIter, TOut, TOutIter, F> InOut<TInIter, TOutIter> for FlatMap<TIn, TOut, F>
where TIn: Send + Clone + IntoIterator, TInIter: IntoIterator<Item = TIn>, TOut: Send + Clone + Iterator + 'static, TOutIter: FromIterator<<TOut as Iterator>::Item>, F: FnOnce(TIn) -> TOut + Send + Copy,

source§

impl<TIn, TInIter, TOut, TOutIter, F> InOut<TInIter, TOutIter> for Map<TIn, TOut, F>
where TIn: Send + Clone, TInIter: IntoIterator<Item = TIn>, TOut: Send + Clone + 'static, TOutIter: FromIterator<TOut>, F: FnOnce(TIn) -> TOut + Send + Copy,

source§

impl<TIn, TInIter, TOut, TOutIter, F> InOut<TInIter, TOutIter> for OrderedFlatMap<TIn, TOut, F>
where TIn: Send + Clone + IntoIterator, TInIter: IntoIterator<Item = TIn>, TOut: Send + Clone + Iterator + 'static, TOutIter: FromIterator<<TOut as Iterator>::Item>, F: FnOnce(TIn) -> TOut + Send + Copy,

source§

impl<TIn, TInIter, TOut, TOutIter, F> InOut<TInIter, TOutIter> for OrderedMap<TIn, TOut, F>
where TIn: Send + Clone, TInIter: IntoIterator<Item = TIn>, TOut: Send + Clone + 'static, TOutIter: FromIterator<TOut>, F: FnOnce(TIn) -> TOut + Send + Copy,

source§

impl<TIn, TMapOut, TInIter, TKey, TOutIter, FMap, FReduce> InOut<TInIter, TOutIter> for MapReduce<TIn, TMapOut, TKey, FMap, FReduce>
where TIn: Send + Clone + 'static, TMapOut: Send + Clone + 'static, TInIter: IntoIterator<Item = TIn>, TKey: Send + Clone + 'static + Ord, TOutIter: FromIterator<(TKey, TMapOut)>, FMap: FnOnce(TIn) -> (TKey, TMapOut) + Send + Copy, FReduce: FnOnce(TMapOut, TMapOut) -> TMapOut + Send + Copy + Sync,

source§

impl<TIn, TMapOut, TInIter, TKey, TOutIter, FMap, FReduce> InOut<TInIter, TOutIter> for OrderedMapReduce<TIn, TMapOut, TKey, FMap, FReduce>
where TIn: Send + Clone + 'static, TMapOut: Send + Clone + 'static, TInIter: IntoIterator<Item = TIn>, TKey: Send + Clone + 'static + Ord, TOutIter: FromIterator<(TKey, TMapOut)>, FMap: FnOnce(TIn) -> (TKey, TMapOut) + Send + Copy, FReduce: FnOnce(TMapOut, TMapOut) -> TMapOut + Send + Copy + Sync,

source§

impl<TIn, TOut, F> InOut<TIn, TOut> for F
where F: FnMut(TIn) -> Option<TOut> + Send + Sync + 'static + Clone,