CanCreateChannels

Trait CanCreateChannels 

Source
pub trait CanCreateChannels: HasChannelTypes {
    // Required method
    fn new_channel<T>() -> (Self::Sender<T>, Self::Receiver<T>)
       where T: Async;
}
Expand description

Allow the creation of new sender-receiver pairs for the channel types defined in HasChannelTypes.

Required Methods§

Source

fn new_channel<T>() -> (Self::Sender<T>, Self::Receiver<T>)
where T: Async,

Given a generic payload type T, create a Sender<T> and Receiver<T> pair that are connected.

The returned sender-receiver pair is expected to satisfy the following invariants:

  • Messages sent from the returned sender are expected to be received via the returned receiver.

  • Messages sent from mismatch sender should never be received by the given receiver.

More invariants may be added in the future to better specify the requirements of the abstract channel. For now, we assume that mainstream implementation of Rust channels can all satisfy the same requirements.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Runtime> CanCreateChannels for Runtime
where Runtime: HasChannelTypes + HasComponents, Runtime::Components: ChannelCreator<Runtime>,

Allow the creation of new sender-receiver pairs for the channel types defined in HasChannelTypes.