Skip to main content

Decode

Derive Macro Decode 

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

Derive the Decode trait for a message.

A #[codec(..)] attribute must be present to select the deserialization 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 target type must be convertible from the bridge type with impl TryFrom<T> for Self and use DecodeError as the error type.

§Example

use acktor_derive::Decode;

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