Skip to main content

Decode

Derive Macro Decode 

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

Derive the Decode trait for a message.

A #[codec(..)] attribute must be present to select the deserialization backend. The same attribute is shared with Encode — 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 Decode::ID constant to the given u64 literal. The value in Encode and Decode must match for the same message type.

§Example

use acktor_derive::Decode;

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