Macro wsbps::packet_data
source · [−]macro_rules! packet_data {
(
$(
$Keyword:ident $Name:ident $Mode:tt $(($Type:ty))? {
$(
$Field:ident:$($EnumValue:literal)?$($FieldType:ty)?
),* $(,)?
}
)*
) => { ... };
}
Expand description
Packet Data
This macro is used to implement read and write traits for enums so they can be used within packets as packet fields. This is a block and you should use it to implement all of your structs and enums at once.
Directions
(<->) Bi-Direction: This implements both readers and writers for this data. This should be used in structs and enums that are shared between readable and writable packets.
(->) Write-Only: This implements only the writers for this data. This should be used if the struct/enum is only going to be sent and not received.
(<-) Read-Only: This implements only the readers for this data. This should be used if the struct/enum is only going to be received and not send.
Example
use wsbps::packet_data;
packet_data! {
struct ExampleBiStruct (<->) {
Field: u8,
Name: String
}
enum TestWriteEnum (->) (u8) {
A: 1,
B: 2
}
}