Trait ChannelUser

Source
pub trait ChannelUser<Runtime>
where Runtime: HasChannelTypes + HasErrorType,
{ // Required methods fn send<T>( sender: &Runtime::Sender<T>, value: T, ) -> impl Future<Output = Result<(), Runtime::Error>> + Send where T: Async; fn receive<T>( receiver: &mut Runtime::Receiver<T>, ) -> impl Future<Output = Result<T, Runtime::Error>> + Send where T: Async; fn try_receive<T>( receiver: &mut Runtime::Receiver<T>, ) -> Result<Option<T>, Runtime::Error> where T: Async; }
Expand description

Allow the sending and receiving of message payloads over the Sender and Receiver ends of a channel.

Required Methods§

Source

fn send<T>( sender: &Runtime::Sender<T>, value: T, ) -> impl Future<Output = Result<(), Runtime::Error>> + Send
where T: Async,

Given a reference to Sender<T>, send a message payload of type T over the sender.

If the receiver side of the channel has been dropped, the sending would fail and an error will be returned.

The sending operation is synchronous. This ensures the payload is guaranteed to be in the channel queue after send() is called.

The receiving operation is expected to be asynchronous. This means that any operation after receive() is called on the receiving end should never execute within send().

Source

fn receive<T>( receiver: &mut Runtime::Receiver<T>, ) -> impl Future<Output = Result<T, Runtime::Error>> + Send
where T: Async,

Given a reference to Receiver<T>, asynchronously receive a message payload of type T that is sent over the sender end.

If the sender end is dropped before any value is sent, this would result in an error in receive()

Source

fn try_receive<T>( receiver: &mut Runtime::Receiver<T>, ) -> Result<Option<T>, Runtime::Error>
where T: Async,

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<Component, Runtime> ChannelUser<Runtime> for Component
where Runtime: HasChannelTypes + HasErrorType, Component: DelegateComponent<ChannelUserComponent>, Component::Delegate: ChannelUser<Runtime>,

Allow the sending and receiving of message payloads over the Sender and Receiver ends of a channel.