pub struct AsyncStreamSender<T> { /* private fields */ }Expand description
Producer handle for a BoundedAsyncStream.
Cheap to clone (Arc under the hood). Drop the last AsyncStreamSender
to close the stream; the consumer’s next() will yield None once the
buffer is empty.
Implementations§
Source§impl<T> AsyncStreamSender<T>
impl<T> AsyncStreamSender<T>
Sourcepub fn push(&self, item: T)
pub fn push(&self, item: T)
Push an item; drops the oldest queued item if the buffer is at capacity. This is the lossy default.
§Panics
Panics if the shared state mutex is poisoned.
Sourcepub fn push_or_block(&self, item: T) -> Result<(), T>
pub fn push_or_block(&self, item: T) -> Result<(), T>
Push an item, blocking the current thread if the buffer is full until the consumer drains an item.
Returns Err(item) if the consumer side has been dropped — the
item is returned to the caller so it isn’t leaked.
§Errors
Returns Err(item) if the consumer has been dropped.
§Panics
Panics if the shared state mutex is poisoned.
Sourcepub fn buffered_count(&self) -> usize
pub fn buffered_count(&self) -> usize
Returns the number of items currently buffered.
§Panics
Panics if the shared state mutex is poisoned.
Sourcepub fn is_consumer_gone(&self) -> bool
pub fn is_consumer_gone(&self) -> bool
Returns true if the consumer has been dropped.
§Panics
Panics if the shared state mutex is poisoned.