Skip to main content

ResultStream

Trait ResultStream 

Source
pub trait ResultStream<'scope, T: Timestamp, D: 'static, E: 'static> {
    // Required methods
    fn ok(self) -> StreamVec<'scope, T, D>;
    fn err(self) -> StreamVec<'scope, T, E>;
    fn map_ok<D2: 'static, L: FnMut(D) -> D2 + 'static>(
        self,
        logic: L,
    ) -> StreamVec<'scope, T, Result<D2, E>>;
    fn map_err<E2: 'static, L: FnMut(E) -> E2 + 'static>(
        self,
        logic: L,
    ) -> StreamVec<'scope, T, Result<D, E2>>;
    fn and_then<D2: 'static, L: FnMut(D) -> Result<D2, E> + 'static>(
        self,
        logic: L,
    ) -> StreamVec<'scope, T, Result<D2, E>>;
    fn unwrap_or_else<L: FnMut(E) -> D + 'static>(
        self,
        logic: L,
    ) -> StreamVec<'scope, T, D>;
}
Expand description

Extension trait for StreamVec.

Required Methods§

Source

fn ok(self) -> StreamVec<'scope, T, D>

Returns a new instance of self containing only ok records.

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

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

fn err(self) -> StreamVec<'scope, T, E>

Returns a new instance of self containing only err records.

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

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

fn map_ok<D2: 'static, L: FnMut(D) -> D2 + 'static>( self, logic: L, ) -> StreamVec<'scope, T, Result<D2, E>>

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

§Examples
use timely::dataflow::operators::{ToStream, Inspect, vec::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: 'static, L: FnMut(E) -> E2 + 'static>( self, logic: L, ) -> StreamVec<'scope, T, Result<D, E2>>

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

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

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

fn and_then<D2: 'static, L: FnMut(D) -> Result<D2, E> + 'static>( self, logic: L, ) -> StreamVec<'scope, T, Result<D2, E>>

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

§Examples
use timely::dataflow::operators::{ToStream, Inspect, vec::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) -> D + 'static>( self, logic: L, ) -> StreamVec<'scope, T, D>

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

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

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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'scope, T: Timestamp, D: 'static, E: 'static> ResultStream<'scope, T, D, E> for StreamVec<'scope, T, Result<D, E>>