macro_rules! packets {
(
$(
$Group:ident $Mode:tt {
$(
$Name:ident ($ID:literal) {
$($Field:ident: $Type:ty),* $(,)?
}
)*
}
)*
) => { ... };
}Expand description
§Packets Macro
This macro is used to define packet groups. It implements the structs for each packet along with their readers and writers (if they require them) and an enum for the packet group to read packets.
§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::packets;
packets! {
BiPackets (<->) {
APacket (0x02) {
User: u8,
Name: String
}
BPacket (0x05) {
Name: String
}
}
ServerPackets (->) {
CPacket (0x02) {
User: u8,
Name: String
}
DPacket (0x05) {
Name: String
}
}
}