protocol: Implement PacketType for Packet.

This commit is contained in:
Ben Reeves 2022-01-17 21:17:08 -06:00
parent dfbfeddfdf
commit 9fca0221db
1 changed files with 26 additions and 0 deletions

View File

@ -90,6 +90,32 @@ macro_rules! state_packets {
)+
}
impl PacketType for Packet {
fn packet_id(&self, version: i32) -> i32 {
match self {
$(
$(
$(
Self::$name(p) => p.packet_id(version),
)*
)+
)+
}
}
fn write<W: io::Write>(&self, buf: &mut W) -> Result<(), Error> {
match self {
$(
$(
$(
Self::$name(p) => p.write(buf),
)*
)+
)+
}
}
}
$(
pub mod $state {