ParAsyncBuilder

Struct ParAsyncBuilder 

Source
pub struct ParAsyncBuilder<St, Fac>
where St: ?Sized + Stream, St::Item: 'static + Send, Fac: FutureFactory<St::Item>, Fac::Fut: 'static + Send + Future, <Fac::Fut as Future>::Output: Send,
{ /* private fields */ }
Expand description

The parallel stream builder with scheduled asynchronous tasks.

Implementations§

Source§

impl<St, Fac> ParAsyncBuilder<St, Fac>
where St: Stream, St::Item: 'static + Send, Fac: 'static + Send + FutureFactory<St::Item>, Fac::Fut: 'static + Send + Future, <Fac::Fut as Future>::Output: 'static + Send,

Source

pub fn map_async<NewFac, NewFut>( self, new_fac: NewFac, ) -> ParAsyncBuilder<St, ComposeFutureFactory<St::Item, Fac, NewFac>>
where NewFac: 'static + Send + Clone + FnMut(<Fac::Fut as Future>::Output) -> NewFut, NewFut: 'static + Send + Future, NewFut::Output: 'static + Send,

Schedule an asynchronous task.

Source

pub fn map_blocking<NewOut, NewFac, NewFunc>( self, new_fac: NewFac, ) -> ParAsyncTailBlockBuilder<St, Fac, NewFac, NewOut>
where NewFac: 'static + Send + Clone + FnMut(<Fac::Fut as Future>::Output) -> NewFunc, NewFunc: 'static + Send + FnOnce() -> NewOut, NewFunc::Output: 'static + Send,

Schedules a blocking task.

The worker thread will pass the blocking task to a blocking thread and wait for the task to finish. It will introduce overhead on spawning blocking threads.

Source

pub fn build_unordered_stream<P>( self, params: P, ) -> UnorderedStream<<Fac::Fut as Future>::Output>
where St: 'static + Send, P: Into<ParParams>,

Creates a stream that runs scheduled parallel tasks, which output does not respect the input order.

Source

pub fn build_ordered_stream<P>( self, params: P, ) -> OrderedStream<<Fac::Fut as Future>::Output>
where St: 'static + Send, P: Into<ParParams>,

Creates a stream that runs scheduled parallel tasks, which output respects the input order.

Source§

impl<St, Fac> ParAsyncBuilder<St, Fac>
where St: 'static + Send + Stream, St::Item: 'static + Send, Fac: 'static + Send + FutureFactory<St::Item>, Fac::Fut: 'static + Send + Future<Output = ()>,

Source

pub async fn for_each<P>(self, params: P)
where P: Into<ParParams>,

Runs parallel tasks on each stream item.

Source§

impl<St, Fac, Error> ParAsyncBuilder<St, Fac>
where St: 'static + Send + Stream, St::Item: 'static + Send, Fac: 'static + Send + FutureFactory<St::Item>, Fac::Fut: 'static + Send + Future<Output = Result<(), Error>>, Error: 'static + Send,

Source

pub async fn try_for_each<P>(self, params: P) -> Result<(), Error>
where P: Into<ParParams>,

Runs parallel tasks on each stream item.

Auto Trait Implementations§

§

impl<St, Fac> Freeze for ParAsyncBuilder<St, Fac>
where Fac: Freeze, St: Freeze + ?Sized,

§

impl<St, Fac> RefUnwindSafe for ParAsyncBuilder<St, Fac>
where Fac: RefUnwindSafe, St: RefUnwindSafe + ?Sized,

§

impl<St, Fac> Send for ParAsyncBuilder<St, Fac>
where Fac: Send, St: Send + ?Sized,

§

impl<St, Fac> Sync for ParAsyncBuilder<St, Fac>
where Fac: Sync, St: Sync + ?Sized,

§

impl<St, Fac> Unpin for ParAsyncBuilder<St, Fac>
where Fac: Unpin, St: Unpin + ?Sized,

§

impl<St, Fac> UnwindSafe for ParAsyncBuilder<St, Fac>
where Fac: UnwindSafe, St: UnwindSafe + ?Sized,

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.