Skip to main content

Encode

Derive Macro Encode 

Source
#[derive(Encode)]
{
    // Attributes available to this derive:
    #[codec]
    #[index]
}
Expand description

Derive the Encode trait for a message.

A #[codec(..)] attribute must be present to select the serialization backend. The same attribute is shared with Decode — encoding and decoding of the same type must use the same backend, so there is no need to distinguish them:

A #[index(N)] attribute must also be present and sets the Encode::ID constant to the given u64 literal. The value in Encode and Decode must match for the same message type.

§Example

use acktor_derive::Encode;

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