From c77e4e82a28e1766eadb5096c38c31df69fcc84e Mon Sep 17 00:00:00 2001 From: Joey Sacchini Date: Tue, 20 Oct 2020 18:49:58 -0400 Subject: Make mc_serialize_body it's own member of Packet trait instead of using Serialize --- src/protocol.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/protocol.rs') diff --git a/src/protocol.rs b/src/protocol.rs index eb903b5..7a13175 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -42,7 +42,7 @@ impl State { pub struct Id { pub id: i32, pub state: State, - pub direction: PacketDirection + pub direction: PacketDirection, } impl Serialize for Id { @@ -87,12 +87,14 @@ pub struct ProtocolPacketField { pub kind: String, } -pub trait Packet: Serialize { +pub trait Packet: Sized { fn id(&self) -> Id; fn version() -> crate::types::VarInt; fn mc_deserialize(raw: RawPacket<'_>) -> Result; + + fn mc_serialize_body(&self, to: &mut S) -> SerializeResult where S: Serializer; } pub enum PacketErr { @@ -284,10 +286,8 @@ macro_rules! define_protocol { other => Err(UnknownId(other.into())), } } - } - impl crate::Serialize for $packett { - fn mc_serialize(&self, to: &mut S) -> crate::SerializeResult { + fn mc_serialize_body(&self, to: &mut S) -> crate::SerializeResult where S: crate::Serializer { use self::$packett::*; match self { $($nam(body) => to.serialize_other(body)),+ -- cgit