From f1a817d4472d2d4bc8ce8321e741a63d8e3bf92a Mon Sep 17 00:00:00 2001 From: vagola Date: Mon, 30 Dec 2019 20:42:06 +0300 Subject: [PATCH] Rename trait packet to packet parser --- protocol-derive/src/lib.rs | 2 +- protocol/src/game.rs | 14 +++++++------- protocol/src/lib.rs | 2 +- protocol/src/login.rs | 20 ++++++++++---------- protocol/src/status.rs | 8 ++++---- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/protocol-derive/src/lib.rs b/protocol-derive/src/lib.rs index cb1d6b5..cba3466 100644 --- a/protocol-derive/src/lib.rs +++ b/protocol-derive/src/lib.rs @@ -10,7 +10,7 @@ pub fn derive_packet(input: TokenStream) -> TokenStream { let name = input.ident; let output = quote! { - impl crate::Packet for #name { + impl crate::PacketParser for #name { type Output = Self; fn encode(&self, writer: &mut W) -> Result<(), EncodeError> { diff --git a/protocol/src/game.rs b/protocol/src/game.rs index e14a6ae..b387153 100644 --- a/protocol/src/game.rs +++ b/protocol/src/game.rs @@ -4,7 +4,7 @@ use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use num_derive::{FromPrimitive, ToPrimitive}; use crate::chat::Message; -use crate::{DecodeError, EncodeError, Packet, PacketRead, PacketWrite}; +use crate::{DecodeError, EncodeError, PacketParser, PacketRead, PacketWrite}; use mc_varint::{VarIntRead, VarIntWrite}; use nbt::CompoundTag; @@ -97,7 +97,7 @@ impl ServerBoundChatMessage { } } -impl Packet for ServerBoundChatMessage { +impl PacketParser for ServerBoundChatMessage { type Output = Self; fn encode(&self, writer: &mut W) -> Result<(), EncodeError> { @@ -131,7 +131,7 @@ impl ClientBoundChatMessage { } } -impl Packet for ClientBoundChatMessage { +impl PacketParser for ClientBoundChatMessage { type Output = Self; fn encode(&self, writer: &mut W) -> Result<(), EncodeError> { @@ -195,7 +195,7 @@ impl JoinGame { } } -impl Packet for JoinGame { +impl PacketParser for JoinGame { type Output = Self; fn encode(&self, writer: &mut W) -> Result<(), EncodeError> { @@ -243,7 +243,7 @@ impl ServerBoundKeepAlive { } } -impl Packet for ServerBoundKeepAlive { +impl PacketParser for ServerBoundKeepAlive { type Output = Self; fn encode(&self, writer: &mut W) -> Result<(), EncodeError> { @@ -271,7 +271,7 @@ impl ClientBoundKeepAlive { } } -impl Packet for ClientBoundKeepAlive { +impl PacketParser for ClientBoundKeepAlive { type Output = Self; fn encode(&self, writer: &mut W) -> Result<(), EncodeError> { @@ -321,7 +321,7 @@ impl ChunkData { } } -impl Packet for ChunkData { +impl PacketParser for ChunkData { type Output = Self; fn encode(&self, writer: &mut W) -> Result<(), EncodeError> { diff --git a/protocol/src/lib.rs b/protocol/src/lib.rs index 4347cd1..cef45e3 100644 --- a/protocol/src/lib.rs +++ b/protocol/src/lib.rs @@ -125,7 +125,7 @@ impl From for DecodeError { } } -trait Packet { +trait PacketParser { type Output; fn encode(&self, writer: &mut W) -> Result<(), EncodeError>; diff --git a/protocol/src/login.rs b/protocol/src/login.rs index 8891408..89dc1e6 100644 --- a/protocol/src/login.rs +++ b/protocol/src/login.rs @@ -4,7 +4,7 @@ use mc_varint::{VarIntRead, VarIntWrite}; use uuid::Uuid; use crate::chat::Message; -use crate::{DecodeError, EncodeError, Packet, PacketRead, PacketWrite, STRING_MAX_LENGTH}; +use crate::{DecodeError, EncodeError, PacketParser, PacketRead, PacketWrite, STRING_MAX_LENGTH}; const LOGIN_MAX_LENGTH: u32 = 16; const SERVER_ID_MAX_LENGTH: u32 = 20; @@ -118,7 +118,7 @@ impl LoginStart { } } -impl Packet for LoginStart { +impl PacketParser for LoginStart { type Output = Self; fn encode(&self, writer: &mut W) -> Result<(), EncodeError> { @@ -148,7 +148,7 @@ impl EncryptionResponse { } } -impl Packet for EncryptionResponse { +impl PacketParser for EncryptionResponse { type Output = Self; fn encode(&self, writer: &mut W) -> Result<(), EncodeError> { @@ -187,7 +187,7 @@ impl LoginPluginResponse { } } -impl Packet for LoginPluginResponse { +impl PacketParser for LoginPluginResponse { type Output = Self; fn encode(&self, writer: &mut W) -> Result<(), EncodeError> { @@ -225,7 +225,7 @@ impl LoginDisconnect { } } -impl Packet for LoginDisconnect { +impl PacketParser for LoginDisconnect { type Output = Self; fn encode(&self, writer: &mut W) -> Result<(), EncodeError> { @@ -263,7 +263,7 @@ impl EncryptionRequest { } } -impl Packet for EncryptionRequest { +impl PacketParser for EncryptionRequest { type Output = Self; fn encode(&self, writer: &mut W) -> Result<(), EncodeError> { @@ -300,7 +300,7 @@ impl LoginSuccess { } } -impl Packet for LoginSuccess { +impl PacketParser for LoginSuccess { type Output = Self; fn encode(&self, writer: &mut W) -> Result<(), EncodeError> { @@ -334,7 +334,7 @@ impl SetCompression { } } -impl Packet for SetCompression { +impl PacketParser for SetCompression { type Output = Self; fn encode(&self, writer: &mut W) -> Result<(), EncodeError> { @@ -368,7 +368,7 @@ impl LoginPluginRequest { } } -impl Packet for LoginPluginRequest { +impl PacketParser for LoginPluginRequest { type Output = Self; fn encode(&self, writer: &mut W) -> Result<(), EncodeError> { @@ -397,7 +397,7 @@ impl Packet for LoginPluginRequest { mod tests { use crate::login::LoginPluginResponse; use crate::login::LoginStart; - use crate::Packet; + use crate::PacketParser; use std::io::Cursor; #[test] diff --git a/protocol/src/status.rs b/protocol/src/status.rs index e617580..110b325 100644 --- a/protocol/src/status.rs +++ b/protocol/src/status.rs @@ -4,7 +4,7 @@ use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use serde::{Deserialize, Serialize}; use uuid::Uuid; -use crate::{DecodeError, EncodeError, Packet, PacketWrite, STRING_MAX_LENGTH}; +use crate::{DecodeError, EncodeError, PacketParser, PacketWrite, STRING_MAX_LENGTH}; pub enum StatusServerBoundPacket { StatusRequest, @@ -58,7 +58,7 @@ impl PingRequest { } } -impl Packet for PingRequest { +impl PacketParser for PingRequest { type Output = Self; fn encode(&self, writer: &mut W) -> Result<(), EncodeError> { @@ -86,7 +86,7 @@ impl PingResponse { } } -impl Packet for PingResponse { +impl PacketParser for PingResponse { type Output = Self; fn encode(&self, writer: &mut W) -> Result<(), EncodeError> { @@ -140,7 +140,7 @@ impl StatusResponse { } } -impl Packet for StatusResponse { +impl PacketParser for StatusResponse { type Output = Self; fn encode(&self, writer: &mut W) -> Result<(), EncodeError> {