#[derive(Protocol)]
Expand description

Implements the Protocol trait for this type.

The network representation is very simple:

  • Attempting to read an enum with no variants errors immediately, without waiting for data to appear on the stream.
  • For non-empty enums, the representation starts with the discriminant (a number representing the variant), starting with 0 for the first variant declared and so on.
    • For enums with up to 256 variants, the discriminant is represented as a u8. For enums with 257 to 65536 variants, as a u16, and so on.
  • Then follow the Protocol representations of any fields of the struct or variant, in the order declared.

This representation can waste bandwidth for some types, e.g. structs with multiple bool fields. For those, you may want to implement Protocol manually.

Compile errors

  • This macro can’t be used with unions.
  • This macro currently can’t be used with generics.