[−][src]Trait lifeline::Channel
A channel's (Sender, Receiver) pair. Defines how the bus constructs and retrieves the values.
Channel endpoints can either be taken, or cloned. The Channel
trait has default implementations that honor the
Storage
trait implementation of channel endpoints. However, in some cases (such as tokio broadcast channels) the tx & rx endpoints are both required to implement this trait.
Associated Types
type Tx: Storage + Send + 'static
[src]
The Sender half of the channel. This is used in Message
implementations to attach channels to a Bus
.
type Rx: Storage + Send + 'static
[src]
The Receiver half of the channel. This is constructed when bus.tx
or bus.rx
is called, and is driven by the Message
implementation for the message.
Required methods
pub fn channel(capacity: usize) -> (Self::Tx, Self::Rx)
[src]
Constructs a new (Sender, Receiver)
pair. If the channel is bounded, use the provided capacity.
pub fn default_capacity() -> usize
[src]
If the channel is bounded, provide a default capacity hint. Users can override this with bus.capacity(usize)
Provided methods
pub fn clone_tx(tx: &mut Option<Self::Tx>) -> Option<Self::Tx>
[src]
Clones the Self::Tx value, or takes it from the option if this endpoint is not cloneable.
pub fn clone_rx(
rx: &mut Option<Self::Rx>,
_tx: Option<&Self::Tx>
) -> Option<Self::Rx>
[src]
rx: &mut Option<Self::Rx>,
_tx: Option<&Self::Tx>
) -> Option<Self::Rx>
Clones the Self::Rx value, or takes it from the option if this endpoint is not cloneable. The Tx endpoint is also available, which is necessary to implement Channel for broadcast channels (where new receivers are created from a tx subscription call)
Implementations on Foreign Types
impl<T: Send + 'static> Channel for Sender<T>
[src]
type Tx = Self
type Rx = Receiver<T>
pub fn channel(capacity: usize) -> (Self::Tx, Self::Rx)
[src]
pub fn default_capacity() -> usize
[src]
impl<T: Send + Clone + 'static> Channel for Sender<T>
[src]
type Tx = Self
type Rx = Receiver<T>
pub fn channel(capacity: usize) -> (Self::Tx, Self::Rx)
[src]
pub fn default_capacity() -> usize
[src]
pub fn clone_rx(
rx: &mut Option<Self::Rx>,
tx: Option<&Self::Tx>
) -> Option<Self::Rx>
[src]
rx: &mut Option<Self::Rx>,
tx: Option<&Self::Tx>
) -> Option<Self::Rx>
impl<T: Send + 'static> Channel for Sender<T>
[src]
type Tx = Self
type Rx = Receiver<T>
pub fn channel(_capacity: usize) -> (Self::Tx, Self::Rx)
[src]
pub fn default_capacity() -> usize
[src]
impl<T> Channel for Sender<T> where
T: Default + Clone + Send + Sync + 'static,
[src]
T: Default + Clone + Send + Sync + 'static,