Skip to main content

Codec

Trait Codec 

Source
pub trait Codec {
    // Required method
    fn codec_table() -> &'static CodecTable;
}
Expand description

A codec table for encoding messages and decoding message responses.

Each entry in the codec table corresponds to a message type the actor can receive from another actor remotely. It records the message id, an EncodeMsgFn for encoding the message to bytes before sending, and a DecodeResFn for decoding the message response bytes back to the concrete message response type.

For example, if actor B needs to send a message to actor A with A’s Address<A>, B needs to use A’s codec table. Since a copy of the codec table is stored in Address<A>, B has access to it automatically if it has A’s address.

§Implementation

Do not implement this trait yourself! Instead, use #[derive(RemoteAddressable)], which will emit an implementation of this trait for a remote addressable actor.

Required Methods§

Source

fn codec_table() -> &'static CodecTable

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§