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.
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 any mutex is poisoned by another thread panicking while holding it.
Sourcepub fn buffered_count(&self) -> usize
pub fn buffered_count(&self) -> usize
Returns the number of items currently buffered.
Sourcepub fn is_consumer_gone(&self) -> bool
pub fn is_consumer_gone(&self) -> bool
Returns true if the consumer has been dropped.
Trait Implementations§
Source§impl<T> Clone for AsyncStreamSender<T>
impl<T> Clone for AsyncStreamSender<T>
Source§impl<T> Debug for AsyncStreamSender<T>
impl<T> Debug for AsyncStreamSender<T>
Source§impl<T> Drop for AsyncStreamSender<T>
impl<T> Drop for AsyncStreamSender<T>
Auto Trait Implementations§
impl<T> Freeze for AsyncStreamSender<T>
impl<T> RefUnwindSafe for AsyncStreamSender<T>
impl<T> Send for AsyncStreamSender<T>where
T: Send,
impl<T> Sync for AsyncStreamSender<T>where
T: Send,
impl<T> Unpin for AsyncStreamSender<T>
impl<T> UnsafeUnpin for AsyncStreamSender<T>
impl<T> UnwindSafe for AsyncStreamSender<T>
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