Trait timely::dataflow::operators::branch::BranchWhen

source ·
pub trait BranchWhen<T>: Sized {
    // Required method
    fn branch_when(
        condition: impl Fn(&T) -> bool + 'static
    ) -> (Self, Self);
Expand description

Extension trait for Stream.

Required Methods§


fn branch_when(&self, condition: impl Fn(&T) -> bool + 'static) -> (Self, Self)

Takes one input stream and splits it into two output streams. For each time, the supplied closure is called. If it returns true, the records for that will be sent to the second returned stream, otherwise they will be sent to the first.

use timely::dataflow::operators::{ToStream, BranchWhen, Inspect, Delay};

timely::example(|scope| {
    let (before_five, after_five) = (0..10)
        .delay(|x,t| *x) // data 0..10 at time 0..10
        .branch_when(|time| time >= &5);

    before_five.inspect(|x| println!("Times 0-4: {:?}", x));
    after_five.inspect(|x| println!("Times 5 and later: {:?}", x));

Object Safety§

This trait is not object safe.