#[derive(HelperRW)]
{
// Attributes available to this derive:
#[Seek]
#[SeekAfter]
#[Const_u16]
#[Read_default]
#[Skip]
#[Flags]
#[BitFlags]
#[ManualRW]
#[OnlyOn]
#[NotOn]
}
Available on crate feature
derive only.Expand description
Derive macro for protocol::HelperReadWrite.
§Note
This macro makes few assumtions about
- the packet struct:
- Any type must implement
protocol::HelperReadWrite.
- the flags struct:
- All fields must be of type
bool
- the variant enum:
- None of the fields must contain any data.
#[repr(_)]must be set to an integer.- Enum must implement
Copy.
§Attribute explanation
§Container attributes
#[Flags(u*)]makes the struct into a flags struct with the specified length.#[BitFlags(u*)]adds read/write support forbitflagsflags containers.
§Field attributes
#[Seek(_seek-amount_)]sets the padding before the field data.#[SeekAfter(_seek-amount_)]sets the padding after the field data.#[Const_u16(_const-int_)]sets the constant u16 before the field data.#[Read_default]sets the default enum variant for reading.#[Skip]. If applied to a field struct field, then this attribute will skip one bit of the flags.#[ManualRW(_readfn_, _writefn_)]sets the read/write functions for the variant. Specified functions must have the same prototype as theprotocol::HelperReadWritefunctions.#[OnlyOn(_protocol::PacketType_)]. If set then the field will only be read/written if the reader packet type matches the specified packet type.#[NotOn(_protocol::PacketType_)]. If set then the field will only be read/written if the reader packet type differs from the specified packet type.