pub trait TryParallelExt<T, E>where
Self: TryStream<Ok = T, Error = E, Item = Result<T, E>> + Send + Sized,
E: From<JoinError> + From<Error> + Send + 'static,
T: Send + 'static,{
// Required method
fn paralleln_and_then<U, F, N, H>(
self,
h: H,
n: N,
f: F,
) -> impl TryStream<Ok = U, Error = E, Item = Result<U, E>> + Send
where N: Into<Option<usize>>,
H: Into<Option<Handle>>,
F: Fn(Self::Ok) -> Result<U, E> + Clone + Send + 'static,
U: Send + 'static;
// Provided method
fn parallel_and_then<U, F, H>(
self,
h: H,
f: F,
) -> impl TryStream<Ok = U, Error = E, Item = Result<U, E>> + Send
where H: Into<Option<Handle>>,
F: Fn(Self::Ok) -> Result<U, E> + Clone + Send + 'static,
U: Send + 'static { ... }
}Expand description
Adds unordered parallel transformations for fallible streams.
Each closure runs on Tokio’s blocking pool, making these combinators suitable for CPU-bound work rather than asynchronous I/O. Concurrency defaults to the host’s available parallelism.
Required Methods§
Sourcefn paralleln_and_then<U, F, N, H>(
self,
h: H,
n: N,
f: F,
) -> impl TryStream<Ok = U, Error = E, Item = Result<U, E>> + Send
fn paralleln_and_then<U, F, N, H>( self, h: H, n: N, f: F, ) -> impl TryStream<Ok = U, Error = E, Item = Result<U, E>> + Send
Runs a synchronous fallible transform on the blocking pool.
n controls concurrent jobs and defaults to available parallelism; an
explicit zero cannot make progress. Job results are completion ordered,
while source errors bypass f and may overtake queued jobs. Spawned
jobs can continue after the adapter is dropped.
§Panics
Panics when no handle is supplied outside a Tokio runtime context.
Provided Methods§
Sourcefn parallel_and_then<U, F, H>(
self,
h: H,
f: F,
) -> impl TryStream<Ok = U, Error = E, Item = Result<U, E>> + Send
fn parallel_and_then<U, F, H>( self, h: H, f: F, ) -> impl TryStream<Ok = U, Error = E, Item = Result<U, E>> + Send
Runs a synchronous fallible transform at the default parallelism.
The optional handle defaults to the current Tokio runtime. Job results
are completion ordered, while source errors may overtake them; join
failures convert into E. Spawned jobs can continue after the adapter
is dropped.
§Panics
Panics when no handle is supplied outside a Tokio runtime context.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".