Skip to main content

ResultStream

Trait ResultStream 

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

Extension trait for StreamVec.

Required Methods§

Source

fn ok(self) -> StreamVec<S, T>

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<S, 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<T2: 'static, L: FnMut(T) -> T2 + 'static>( self, logic: L, ) -> StreamVec<S, Result<T2, 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<S, Result<T, 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<T2: 'static, L: FnMut(T) -> Result<T2, E> + 'static>( self, logic: L, ) -> StreamVec<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, 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) -> T + 'static>(self, logic: L) -> StreamVec<S, T>

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<S: Scope, T: 'static, E: 'static> ResultStream<S, T, E> for StreamVec<S, Result<T, E>>