Skip to main content

Sink

Struct Sink 

Source
pub struct Sink<A, In, E = (), R = ()>
where A: 'static, In: Send + 'static, E: Send + 'static, R: 'static,
{ /* private fields */ }
Expand description

Consumer that reduces a Stream<In, E, R> to a value of type A.

Implementations§

Source§

impl<A, In, E, R> Sink<A, In, E, R>
where A: 'static, In: Send + 'static, E: Send + 'static, R: 'static,

Source

pub fn run(self, stream: Stream<In, E, R>) -> Effect<A, E, R>

Run this sink over stream.

Source§

impl<A, In, E, R> Sink<A, In, E, R>
where A: Send + Sync + Clone + 'static, In: Send + Sync + Clone + 'static, E: Send + 'static, R: 'static,

Source

pub fn fold_left( init: A, f: impl Fn(A, In) -> A + Send + Sync + 'static, ) -> Self

Left fold over elements (after the stream ends, the accumulator is the result).

Source

pub fn from_fold( init: A, f: impl Fn(A, In) -> A + Send + Sync + 'static, ) -> Self

Alias for Self::fold_left.

Source

pub fn zip<B>(self, other: Sink<B, In, E, R>) -> Sink<(A, B), In, E, R>
where B: Send + Sync + Clone + 'static, In: Clone + Send + 'static,

Combine two Self::fold_left / Self::from_fold sinks into one pass over the stream.

§Panics

Panics if either sink was not built with Self::fold_left / Self::from_fold.

Source§

impl<In, E, R> Sink<Vec<In>, In, E, R>
where In: Send + Sync + Clone + 'static, E: Send + 'static, R: 'static,

Source

pub fn collect() -> Self

Collect all elements into a vector (in stream order).

Source

pub fn collect_all_while(pred: Predicate<In>) -> Self

Take elements while pred holds; stops before the first failing element (that element is not included in the result).

Source

pub fn collect_all_until(pred: Predicate<In>) -> Self

Take elements until pred becomes true; the first matching element is not included.

Source§

impl<In, E, R> Sink<(), In, E, R>
where In: Send + Sync + Clone + 'static, E: Send + 'static, R: 'static,

Source

pub fn drain() -> Self

Discard every element; result is ().

Source

pub fn to_queue(queue: Queue<In>) -> Self

Enqueue each stream element into queue (using () as the queue offer environment).

Source§

impl<K, V, E, R> Sink<EffectHashMap<K, V>, (K, V), E, R>
where K: Hash + Eq + Clone + Send + Sync + 'static, V: Clone + Send + Sync + 'static, E: Send + 'static, R: 'static,

Source

pub fn collect_to_map() -> Self

Collect stream elements (K, V) into an EffectHashMap.

Trait Implementations§

Source§

impl<A, In, E, R> Clone for Sink<A, In, E, R>
where A: 'static, In: Send + 'static, E: Send + 'static, R: 'static,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<A, In, E, R> Freeze for Sink<A, In, E, R>

§

impl<A, In, E = (), R = ()> !RefUnwindSafe for Sink<A, In, E, R>

§

impl<A, In, E, R> Send for Sink<A, In, E, R>
where R: Send, A: Sync + Send,

§

impl<A, In, E, R> Sync for Sink<A, In, E, R>
where E: Sync, R: Sync, A: Sync + Send,

§

impl<A, In, E, R> Unpin for Sink<A, In, E, R>
where E: Unpin, R: Unpin,

§

impl<A, In, E, R> UnsafeUnpin for Sink<A, In, E, R>

§

impl<A, In, E = (), R = ()> !UnwindSafe for Sink<A, In, E, R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pipe for T

Source§

fn pipe<F, R>(self, f: F) -> R
where F: FnOnce(Self) -> R,

Applies f to self (F#-style forward pipe).
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.