Trait timely::dataflow::operators::result::ResultStream[][src]

pub trait ResultStream<S: Scope, T: Data, E: Data> {
    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>; }

Extension trait for Stream.

Required methods

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

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));
});

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

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));
});

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

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));
});

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

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));
});

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

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));
});

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

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));
});
Loading content...

Implementors

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

Loading content...