#[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:
#[codec(prost)]— delegates toprost::Message::decode. The target type (or the bridge type) must implementprost::Message.#[codec(serde_json)]— delegates toserde_json::from_slice. The target type (or the bridge type) must implementserde::Deserialize.#[codec(zerocopy)]— delegates tozerocopy::FromBytes::read_from_bytes. The target type (or the bridge type) must implementzerocopy::FromBytes.#[codec(rkyv)]— delegates torkyv::from_bytes. The target type (or the bridge type) must implementrkyv::Archiveandrkyv::Deserialize.
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);