pub(crate) struct ReceiverStreamBuilder<O> {
tx: Sender<Result<O>>,
rx: Receiver<Result<O>>,
join_set: JoinSet<Result<()>>,
}Expand description
Creates a stream from a collection of producing tasks, routing panics to the stream.
Note that this is similar to ReceiverStream from tokio-stream, with the differences being:
-
Methods to bound and “detach” tasks (
spawn()andspawn_blocking()). -
Propagates panics, whereas the
tokioversion doesn’t propagate panics to the receiver. -
Automatically cancels any outstanding tasks when the receiver stream is dropped.
Fields§
§tx: Sender<Result<O>>§rx: Receiver<Result<O>>§join_set: JoinSet<Result<()>>Implementations§
Source§impl<O: Send + 'static> ReceiverStreamBuilder<O>
impl<O: Send + 'static> ReceiverStreamBuilder<O>
Sourcepub fn spawn<F>(&mut self, task: F)
pub fn spawn<F>(&mut self, task: F)
Spawn task that will be aborted if this builder (or the stream built from it) are dropped
Sourcepub fn spawn_on<F>(&mut self, task: F, handle: &Handle)
pub fn spawn_on<F>(&mut self, task: F, handle: &Handle)
Same as Self::spawn but it spawns the task on the provided runtime
Sourcepub fn spawn_blocking<F>(&mut self, f: F)
pub fn spawn_blocking<F>(&mut self, f: F)
Spawn a blocking task that will be aborted if this builder (or the stream built from it) are dropped.
This is often used to spawn tasks that write to the sender
retrieved from Self::tx.
Sourcepub fn spawn_blocking_on<F>(&mut self, f: F, handle: &Handle)
pub fn spawn_blocking_on<F>(&mut self, f: F, handle: &Handle)
Same as Self::spawn_blocking but it spawns the blocking task on the provided runtime
Auto Trait Implementations§
impl<O> Freeze for ReceiverStreamBuilder<O>
impl<O> !RefUnwindSafe for ReceiverStreamBuilder<O>
impl<O> Send for ReceiverStreamBuilder<O>where
O: Send,
impl<O> Sync for ReceiverStreamBuilder<O>where
O: Send,
impl<O> Unpin for ReceiverStreamBuilder<O>
impl<O> !UnwindSafe for ReceiverStreamBuilder<O>
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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