Skip to main content

Sink

Struct Sink 

Source
pub struct Sink;

Implementations§

Source§

impl Sink

Source

pub async fn fold<T, Acc, F>(source: Source<T>, init: Acc, f: F) -> Acc
where T: Send + 'static, Acc: Send + 'static, F: FnMut(Acc, T) -> Acc + Send + 'static,

Drive the source and accumulate a single value.

Source

pub async fn fold_async<T, Acc, F, Fut>( source: Source<T>, init: Acc, f: F, ) -> Acc
where T: Send + 'static, Acc: Send + 'static, F: FnMut(Acc, T) -> Fut + Send + 'static, Fut: Future<Output = Acc> + Send + 'static,

Async fold.

Source

pub async fn collect<T>(source: Source<T>) -> Vec<T>
where T: Send + 'static,

Collect into a Vec.

Source

pub async fn first<T>(source: Source<T>) -> Option<T>
where T: Send + 'static,

Source

pub async fn last<T>(source: Source<T>) -> Option<T>
where T: Send + 'static,

Source

pub async fn sum<T>(source: Source<T>) -> T
where T: Send + Default + Add<Output = T> + 'static,

Source

pub async fn count<T>(source: Source<T>) -> u64
where T: Send + 'static,

Source

pub async fn for_each<T, F>(source: Source<T>, f: F)
where T: Send + 'static, F: FnMut(T) + Send + 'static,

Source

pub async fn for_each_async<T, F, Fut>( source: Source<T>, parallelism: usize, f: F, )
where T: Send + 'static, F: FnMut(T) -> Fut + Send + 'static, Fut: Future<Output = ()> + Send + 'static,

Source

pub async fn ignore<T: Send + 'static>(source: Source<T>)

Source

pub async fn to_sender<T>(source: Source<T>, tx: UnboundedSender<T>)
where T: Send + 'static,

Send each element to an UnboundedSender. (atomr equivalent uses an mpsc channel).

Source

pub fn queue<T>(source: Source<T>) -> SinkQueue<T>
where T: Send + 'static,

Run the source and expose a pull-based API. The returned SinkQueue::pull future returns Ok(Some(t)) per element, Ok(None) after the stream completes.

Source

pub async fn pull_with_timeout<T: Send + 'static>( q: &SinkQueue<T>, t: Duration, ) -> Option<T>

Sink.Queue with a bounded element timeout per pull.

Auto Trait Implementations§

§

impl Freeze for Sink

§

impl RefUnwindSafe for Sink

§

impl Send for Sink

§

impl Sync for Sink

§

impl Unpin for Sink

§

impl UnsafeUnpin for Sink

§

impl UnwindSafe for Sink

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> 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, 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.