diff options
author | Joey Sacchini <joey@sacchini.net> | 2020-10-20 18:49:58 -0400 |
---|---|---|
committer | Joey Sacchini <joey@sacchini.net> | 2020-10-20 18:49:58 -0400 |
commit | c77e4e82a28e1766eadb5096c38c31df69fcc84e (patch) | |
tree | a8a36a82b38897f81827670e6daca414af289324 /src/protocol.rs | |
parent | bf1e33fcd4cef4acb829f03f0d6b203b45557d77 (diff) | |
download | mcproto-rs-c77e4e82a28e1766eadb5096c38c31df69fcc84e.tar.gz mcproto-rs-c77e4e82a28e1766eadb5096c38c31df69fcc84e.tar.bz2 mcproto-rs-c77e4e82a28e1766eadb5096c38c31df69fcc84e.zip |
Make mc_serialize_body it's own member of Packet trait instead of using Serialize
Diffstat (limited to 'src/protocol.rs')
-rw-r--r-- | src/protocol.rs | 10 |
1 files changed, 5 insertions, 5 deletions
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<Self, PacketErr>; + + fn mc_serialize_body<S>(&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<S: crate::Serializer>(&self, to: &mut S) -> crate::SerializeResult { + fn mc_serialize_body<S>(&self, to: &mut S) -> crate::SerializeResult where S: crate::Serializer { use self::$packett::*; match self { $($nam(body) => to.serialize_other(body)),+ |