Skip to main content

Message

Trait Message 

Source
pub trait Message<L>: Sized {
    // Required methods
    fn upcast(label: L) -> Self;
    fn downcast(self) -> Result<L, Self>;
}
Expand description

This trait represents a message to be exchanged between two participants. The generic type L is the type of the label (i.e. the content of the message).

Required Methods§

Source

fn upcast(label: L) -> Self

Creates a message from a label.

Source

fn downcast(self) -> Result<L, Self>

Tries to get the label contained in the Message. This might fail, typically if we are trying to get a label of the wrong type. In case of failure, the result contains self, hence the message is not lost.

§Errors

Returns Err(self) if the message does not contain a label of type L.

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.

Implementations on Foreign Types§

Source§

impl<L: 'static> Message<L> for Box<dyn Any>

Source§

fn upcast(label: L) -> Self

Source§

fn downcast(self) -> Result<L, Self>

Source§

impl<L: Send + 'static> Message<L> for Box<dyn Any + Send>

Source§

fn upcast(label: L) -> Self

Source§

fn downcast(self) -> Result<L, Self>

Source§

impl<L: Send + Sync + 'static> Message<L> for Box<dyn Any + Send + Sync>

Source§

fn upcast(label: L) -> Self

Source§

fn downcast(self) -> Result<L, Self>

Implementors§