pub struct DeferredStreamProcessor { /* private fields */ }Expand description
Background processor for streams Handles streams to completion, passing each item from the stream to a callback
Implementations§
Source§impl DeferredStreamProcessor
impl DeferredStreamProcessor
Sourcepub fn init(&self)
pub fn init(&self)
Initialize the processor before use
Pairs with terminate. Spawns the background task; not idempotent, calling it twice panics dropping the prior un-awaited join handle.
Sourcepub async fn terminate(&self)
pub async fn terminate(&self)
Terminate the processor and ensure all streams are closed
Awaits the background task’s exit. Idempotent: a no-op once already terminated or never initialized.
Sourcepub fn add_stream<T: Send + 'static, S: Stream<Item = T> + Unpin + Send + 'static>(
&self,
receiver: S,
handler: impl FnMut(T) -> PinBoxFutureStatic<DeferredStreamResult> + Send + 'static,
) -> bool
pub fn add_stream<T: Send + 'static, S: Stream<Item = T> + Unpin + Send + 'static>( &self, receiver: S, handler: impl FnMut(T) -> PinBoxFutureStatic<DeferredStreamResult> + Send + 'static, ) -> bool
Queue a stream to process in the background
- ‘receiver’ is the stream to process
- ‘handler’ is the callback to handle each item from the stream
Returns ‘true’ if the stream was added for processing, and ‘false’ if the stream could not be added, possibly due to not being initialized.
Non-blocking; the stream is processed by the background task until exhausted or terminate is called.
Trait Implementations§
Source§impl Clone for DeferredStreamProcessor
impl Clone for DeferredStreamProcessor
Source§fn clone(&self) -> DeferredStreamProcessor
fn clone(&self) -> DeferredStreamProcessor
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DeferredStreamProcessor
impl Debug for DeferredStreamProcessor
Auto Trait Implementations§
impl !RefUnwindSafe for DeferredStreamProcessor
impl !UnwindSafe for DeferredStreamProcessor
impl Freeze for DeferredStreamProcessor
impl Send for DeferredStreamProcessor
impl Sync for DeferredStreamProcessor
impl Unpin for DeferredStreamProcessor
impl UnsafeUnpin for DeferredStreamProcessor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more