Derive Macro async_proto_derive::Protocol[][src]

#[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 a single u8 representing the variant, starting with 0 for the first variant declared 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 enums with more than u8::MAX variants.