#[derive(Deserialized)]
{
// Attributes available to this derive:
#[wire]
}
Expand description
Derives a self-deserializing input type (Deserialized in the core crate): Deserialize
means the framework’s codec does it, Deserialized means it is already done by the user’s
own type.
Covers the obvious shape - a newtype or single-field struct over the payload view
&'a [u8] - and emits the construction plus both Input spellings, so &Frame<'_> and
&[Frame<'_>] bodies mount.
A type that deserializes itself - a generated Protobuf message, a flatbuffers root, a capnp
reader - names its format’s own reader with #[wire(decode = <path>)] instead, and then the
shape of the type is its own business. The path is a function fn(&[u8]) -> Result<Self, E>
(or fn(&'a [u8]) -> Result<Self<'a>, E> for a borrowing view); the derive calls it and
nothing here depends on the format’s crate. #[wire(prost)] is the shorthand for
prost::Message::decode.
#[derive(Deserialized)]
struct Frame<'a>(&'a [u8]);
#[subscriber("frames")]
async fn inspect(frame: &Frame<'_>) -> HandlerOutcome { /* parse it yourself */ }
// What a generator's config puts on every message it emits.
#[derive(Clone, PartialEq, prost::Message, Deserialized)]
#[wire(prost)]
struct Order { #[prost(uint64, tag = "1")] id: u64 }