Rename trait packet to packet parser
This commit is contained in:
parent
9e1d934049
commit
f1a817d447
@ -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<W: Write>(&self, writer: &mut W) -> Result<(), EncodeError> {
|
||||
|
@ -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<W: Write>(&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<W: Write>(&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<W: Write>(&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<W: Write>(&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<W: Write>(&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<W: Write>(&self, writer: &mut W) -> Result<(), EncodeError> {
|
||||
|
@ -125,7 +125,7 @@ impl From<TagDecodeError> for DecodeError {
|
||||
}
|
||||
}
|
||||
|
||||
trait Packet {
|
||||
trait PacketParser {
|
||||
type Output;
|
||||
|
||||
fn encode<W: Write>(&self, writer: &mut W) -> Result<(), EncodeError>;
|
||||
|
@ -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<W: Write>(&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<W: Write>(&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<W: Write>(&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<W: Write>(&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<W: Write>(&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<W: Write>(&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<W: Write>(&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<W: Write>(&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]
|
||||
|
@ -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<W: Write>(&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<W: Write>(&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<W: Write>(&self, writer: &mut W) -> Result<(), EncodeError> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user