Skip to main content

TypeStructCodec

Derive Macro TypeStructCodec 

Source
#[derive(TypeStructCodec)]
{
    // Attributes available to this derive:
    #[type_struct_codec]
}
Expand description

Re-exports of protocol codec derive macros.

ProtocolEnum implements both ProtocolEnum and TypeCodec for a fieldless enum. TypeStructCodec implements TypeCodec for a structure by processing its fields in declaration order. Derives [mcproto_types::TypeCodec] for a protocol structure.

Fields are encoded and decoded in declaration order. A codec kind must be supplied so errors from individual fields retain the enclosing structure:

#[derive(TypeStructCodec)]
#[type_struct_codec(kind = Slot)]
struct Item {
    id: VarInt,
    count: VarInt,
}