[][src]Trait lifeline::Channel

pub trait Channel {
    type Tx: Storage + Send + 'static;
    type Rx: Storage + Send + 'static;
    fn channel(capacity: usize) -> (Self::Tx, Self::Rx);
fn default_capacity() -> usize; fn clone_tx(tx: &mut Option<Self::Tx>) -> Option<Self::Tx> { ... }
fn clone_rx(
        rx: &mut Option<Self::Rx>,
        _tx: Option<&Self::Tx>
    ) -> Option<Self::Rx> { ... } }

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

The Sender half of the channel. This is used in Message implementations to attach channels to a Bus.

type Rx: Storage + Send + 'static

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.

Loading content...

Required methods

fn channel(capacity: usize) -> (Self::Tx, Self::Rx)

Constructs a new (Sender, Receiver) pair. If the channel is bounded, use the provided capacity.

fn default_capacity() -> usize

If the channel is bounded, provide a default capacity hint. Users can override this with bus.capacity(usize)

Loading content...

Provided methods

fn clone_tx(tx: &mut Option<Self::Tx>) -> Option<Self::Tx>

Clones the Self::Tx value, or takes it from the option if this endpoint is not cloneable.

fn clone_rx(
    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)

Loading content...

Implementations on Foreign Types

impl<T: Send + 'static> Channel for Sender<T>[src]

type Tx = Self

type Rx = Receiver<T>

impl<T: Send + 'static> Channel for Sender<T>[src]

type Tx = Self

type Rx = Receiver<T>

impl<T: Send + 'static> Channel for Sender<T>[src]

type Tx = Self

type Rx = Receiver<T>

impl<T> Channel for Sender<T> where
    T: Default + Clone + Send + Sync + 'static, 
[src]

type Tx = Self

type Rx = Receiver<T>

Loading content...

Implementors

impl<T: Clone + Default + Send + Sync + 'static> Channel for Barrier<T>[src]

type Tx = Barrier<T>

type Rx = BarrierReceiver<T>

Loading content...