Trait timely::dataflow::operators::result::ResultStream

source ·
pub trait ResultStream<S: Scope, T: Data, E: Data> {
    // Required methods
    fn ok(&self) -> Stream<S, T>;
    fn err(&self) -> Stream<S, E>;
    fn map_ok<T2: Data, L: FnMut(T) -> T2 + 'static>(
        &self,
        logic: L,
    ) -> Stream<S, Result<T2, E>>;
    fn map_err<E2: Data, L: FnMut(E) -> E2 + 'static>(
        &self,
        logic: L,
    ) -> Stream<S, Result<T, E2>>;
    fn and_then<T2: Data, L: FnMut(T) -> Result<T2, E> + 'static>(
        &self,
        logic: L,
    ) -> Stream<S, Result<T2, E>>;
    fn unwrap_or_else<L: FnMut(E) -> T + 'static>(
        &self,
        logic: L,
    ) -> Stream<S, T>;
}
Expand description

Extension trait for Stream.

Required Methods§

source

fn ok(&self) -> Stream<S, T>

Returns a new instance of self containing only ok records.

§Examples
use timely::dataflow::operators::{ToStream, Inspect, ResultStream};

timely::example(|scope| {
    vec![Ok(0), Err(())].to_stream(scope)
           .ok()
           .inspect(|x| println!("seen: {:?}", x));
});
source

fn err(&self) -> Stream<S, E>

Returns a new instance of self containing only err records.

§Examples
use timely::dataflow::operators::{ToStream, Inspect, ResultStream};

timely::example(|scope| {
    vec![Ok(0), Err(())].to_stream(scope)
           .err()
           .inspect(|x| println!("seen: {:?}", x));
});
source

fn map_ok<T2: Data, L: FnMut(T) -> T2 + 'static>( &self, logic: L, ) -> Stream<S, Result<T2, E>>

Returns a new instance of self applying logic on all Ok records.

§Examples
use timely::dataflow::operators::{ToStream, Inspect, ResultStream};

timely::example(|scope| {
    vec![Ok(0), Err(())].to_stream(scope)
           .map_ok(|x| x + 1)
           .inspect(|x| println!("seen: {:?}", x));
});
source

fn map_err<E2: Data, L: FnMut(E) -> E2 + 'static>( &self, logic: L, ) -> Stream<S, Result<T, E2>>

Returns a new instance of self applying logic on all Err records.

§Examples
use timely::dataflow::operators::{ToStream, Inspect, ResultStream};

timely::example(|scope| {
    vec![Ok(0), Err(())].to_stream(scope)
           .map_err(|_| 1)
           .inspect(|x| println!("seen: {:?}", x));
});
source

fn and_then<T2: Data, L: FnMut(T) -> Result<T2, E> + 'static>( &self, logic: L, ) -> Stream<S, Result<T2, E>>

Returns a new instance of self applying logic on all Ok records, passes through Err records.

§Examples
use timely::dataflow::operators::{ToStream, Inspect, ResultStream};

timely::example(|scope| {
    vec![Ok(0), Err(())].to_stream(scope)
           .and_then(|x| Ok(1 + 1))
           .inspect(|x| println!("seen: {:?}", x));
});
source

fn unwrap_or_else<L: FnMut(E) -> T + 'static>(&self, logic: L) -> Stream<S, T>

Returns a new instance of self applying logic on all Ok records.

§Examples
use timely::dataflow::operators::{ToStream, Inspect, ResultStream};

timely::example(|scope| {
    vec![Ok(1), Err(())].to_stream(scope)
           .unwrap_or_else(|_| 0)
           .inspect(|x| println!("seen: {:?}", x));
});

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<S: Scope, T: Data, E: Data> ResultStream<S, T, E> for Stream<S, Result<T, E>>