#[derive(PacketRW)]
{
// Attributes available to this derive:
#[Id]
#[Seek]
#[SeekAfter]
#[Const_u16]
#[Flags]
#[Magic]
#[OnlyOn]
#[NotOn]
}
Available on crate feature
derive only.Expand description
Derive macro for protocol::PacketReadWrite.
§Note
This macro makes few assumtions about the packet struct:
- The only container type currently allowed is
Vec<T>. - Any type that is not hardcoded (i.e integers, floats,
half::f16,std::net::Ipv4Addr,std::time::Duration,String,AsciiString) must implementprotocol::HelperReadWriteor have theread,writefunctions with the same prototype.
§Attribute explanation
§Container attributes
#[Id(_id_, _subid_)]sets the ID and subID of the packet.#[Flags(_protocol::Flags_)]sets the flags of the packet.#[Magic(_xor_, _sub_)]. If thepackedflag is set, then this attribute sets the deciphering xor and sub for variable length types.
§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.#[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.