Skip to main content

Encode

Derive Macro Encode 

Source
#[derive(Encode)]
{
    // Attributes available to this derive:
    #[codec]
}
Available on crate feature ipc only.
Expand description

Derive the Encode trait for a message.

A #[codec(..)] attribute must be present to select the serialization method and the same attribute is shared with Decode. Encoding and decoding of the same message type must use the same method. The attribute also supports an optional bridge type that serves as an intermediary for encoding and decoding, which is useful when the message type itself cannot directly implement the required traits. Currently there are three supported codec methods:

If a bridge type T is specified, the bridge type must be convertible from the target type with impl From<&Self> for T.

§Example

use acktor_derive::Encode;

#[derive(zerocopy::IntoBytes, Encode)]
#[codec(zerocopy)]
struct Ping(u64);