Derive Macro async_proto_derive::Protocol
source · [−]#[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
enum
s, the representation starts with the discriminant (a number representing the variant), starting with0
for the first variant declared and so on. - Then follow the
Protocol
representations of any fields of thestruct
or variant, in the order declared.
This representation can waste bandwidth for some types, e.g. struct
s with multiple bool
fields. For those, you may want to implement Protocol
manually.
Compile errors
- This macro can’t be used with
union
s. - This macro currently can’t be used with generics.