pub struct Channel<T> { /* private fields */ }Expand description
A closeable bounded MPSC channel whose consumer side is a Source.
Clone the handle for producers. At most one consumer stream may be active at
a time; a second concurrent materialization of the same channel source
returns a StreamError. Dropping the active consumer closes the channel so
blocked producers wake and future sends fail with SendError::Closed.
Capacity must be greater than zero. FS2’s synchronous/rendezvous
bounded(0) mode is deliberately unsupported in this v1 bounded channel.
Implementations§
Source§impl<T> Channel<T>
impl<T> Channel<T>
Sourcepub fn source(&self) -> Source<T>where
T: Send + 'static,
pub fn source(&self) -> Source<T>where
T: Send + 'static,
Return a source blueprint attached to this channel.
Materialization claims the one active consumer slot. A concurrent second
materialization fails with StreamError::Failed.
Sourcepub async fn send(&self, value: T) -> Result<(), SendError<T>>
pub async fn send(&self, value: T) -> Result<(), SendError<T>>
Asynchronously send one value, waiting without spinning while the buffer
is full. Returns SendError::Closed if the channel closes before the
value is accepted.
Sourcepub fn try_send(&self, value: T) -> Result<(), TrySendError<T>>
pub fn try_send(&self, value: T) -> Result<(), TrySendError<T>>
Try to enqueue one value without waiting.