pub struct ContinuousClosureSink<T, E> { /* private fields */ }
Expand description
Block acting as Consumer
, which uses a callback as sink and aborts when
stream is reset
The type argument E
indicates a possible reported error type by the
callback.
Implementations
sourceimpl<T, E> ContinuousClosureSink<T, E>where
T: Clone + Send + Sync + 'static,
E: Send + 'static,
impl<T, E> ContinuousClosureSink<T, E>where
T: Clone + Send + Sync + 'static,
E: Send + 'static,
sourcepub fn new<F>(process: F) -> Selfwhere
F: FnMut(T) -> Result<(), E> + Send + 'static,
pub fn new<F>(process: F) -> Selfwhere
F: FnMut(T) -> Result<(), E> + Send + 'static,
Create block which invokes the process
closure for received data
sourcepub fn new_async<F, R>(process: F) -> Selfwhere
F: FnMut(T) -> R + Send + 'static,
R: Future<Output = Result<(), E>> + Send,
pub fn new_async<F, R>(process: F) -> Selfwhere
F: FnMut(T) -> R + Send + 'static,
R: Future<Output = Result<(), E>> + Send,
Create block which invokes the process
closure for received data and
await
s its result
This function is the same as ContinuousClosureSink::new
but accepts
an asynchronously working closure.
sourcepub async fn wait(self) -> Result<bool, ContinuousClosureSinkError<E>>
pub async fn wait(self) -> Result<bool, ContinuousClosureSinkError<E>>
Wait for stream to finish
Returns Ok(true)
if connected Producer
indicated completion
through Sender::finish
(RecvError::Finished
).
Returns Ok(false)
if operation could not complete because no
Producer
is connected.
sourcepub async fn stop(self) -> Result<bool, ContinuousClosureSinkError<E>>
pub async fn stop(self) -> Result<bool, ContinuousClosureSinkError<E>>
Stop operation
Returns Ok(true)
if connected Producer
indicated completion
through Sender::finish
(RecvError::Finished
).
Returns Ok(false)
if operation was stopped before.
Trait Implementations
sourceimpl<T, E> Consumer<T> for ContinuousClosureSink<T, E>where
T: Clone,
impl<T, E> Consumer<T> for ContinuousClosureSink<T, E>where
T: Clone,
sourcefn receiver_connector(&self) -> &ReceiverConnector<T>
fn receiver_connector(&self) -> &ReceiverConnector<T>
ReceiverConnector
sourcefn feed_from_none(&self)
fn feed_from_none(&self)
Consumer
from any connected Producer
if connectedsourcefn connect_to_producer<P: Producer<T>>(&self, producer: &P)
fn connect_to_producer<P: Producer<T>>(&self, producer: &P)
feed_from
Consumer
to Producer
sourcefn disconnect_from_producer(&self)
fn disconnect_from_producer(&self)
feed_from_none
Consumer
from any connected Producer
if connected