Skip to main content

ProtocolEnum

Derive Macro ProtocolEnum 

Source
#[derive(ProtocolEnum)]
{
    // Attributes available to this derive:
    #[protocol_enum]
}
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::ProtocolEnum] and [mcproto_types::TypeCodec] for a fieldless enum with a numeric protocol representation.

§Example

#[derive(ProtocolEnum)]
#[protocol_enum(repr = VarInt)]
enum GameMode {
    Survival = 0,
    Creative = 1,
}

The repr value must implement [mcproto_types::EnumRepr]. Built-in numeric protocol types, including VarInt, VarLong, and fixed-width integer types, implement that trait.