Skip to main content

MessageSpecifier

Trait MessageSpecifier 

Source
pub trait MessageSpecifier<T>: Sealed {
    type Output: MessageReply + Send;
    type Payload: Send + 'static;

    // Required methods
    fn into_payload(msg: T) -> (Self::Payload, Self::Output);
    fn from_payload(payload: Self::Payload) -> T;
}
Expand description

A trait for types that can be used to specify the kind of a Message.

This trait is sealed and cannot be implemented outside of this crate. Use Request<T> or FireAndForget to specify the kind of a Message.

Required Associated Types§

Source

type Output: MessageReply + Send

The output type of the message.

This must implement MessageReply, and is either Rx<T> for request messages, or () for fire-and-forget messages.

Source

type Payload: Send + 'static

The actual payload of the message.

This is T for fire-and-forget messages, and (T, Tx<R>) for requests.

Required Methods§

Source

fn into_payload(msg: T) -> (Self::Payload, Self::Output)

Convert a message into its payload and output.

Source

fn from_payload(payload: Self::Payload) -> T

Convert a payload back into the message.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<I: Send + 'static, R: Send + 'static> MessageSpecifier<I> for Request<R>

Source§

type Output = Rx<R>

Source§

type Payload = (I, Tx<R>)

Source§

impl<I: Send + 'static> MessageSpecifier<I> for FireAndForget