Add trait to obtain protocol packet ID from packet data

This commit is contained in:
timvisee
2021-11-16 17:56:31 +01:00
parent d26a525c7b
commit 4e6a1f9380
6 changed files with 98 additions and 12 deletions

View File

@@ -1,2 +1,19 @@
pub mod v1_14_4;
pub mod v1_17_1;
/// Trait to obtain packet ID from packet data.
pub trait PacketId {
/// Get protcol packet ID.
fn packet_id(&self) -> u8;
}
#[macro_export]
macro_rules! trait_packet_id (
($type: ident, $id: expr) => (
impl PacketId for $type {
fn packet_id(&self) -> u8 {
$id
}
}
)
);