Derive Macro tora_derive::WriteEnum
source · #[derive(WriteEnum)]
{
// Attributes available to this derive:
#[type_variant_id]
}
Expand description
The WriteEnum derive macro generates a SerializeIo implementation for enums.
Opposite of the ReadEnum macro.
Attributes
type_variant_id($ty)
This attribute tells the macro what type represents the enum variant ID.
The enum variant ID is the number written to notify the reader of the variant they should expect to receive.
use tora_derive::WriteEnum;
#[derive(WriteEnum)]
enum Packet {
PlayerJoin, // 0
PlayerQuit // 1
}By default this macro assumes u8.
In the case that the enum deriving this macro contains more than u8::MAX variants, the user will be required to specify this attribute manually.