From 567c6f4f2c39976d170111b816806453636f8241 Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 1 May 2022 21:54:03 -0500 Subject: Reduce usage of AsyncRead We already receive everything from the server when it tells us the length, so we can actually just treat the stream as a Read instead of an AsyncRead. --- .../packets/game/clientbound_update_attributes_packet.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs') diff --git a/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs index d7f86931..6e0aae29 100644 --- a/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs @@ -1,11 +1,9 @@ -use async_trait::async_trait; -use azalea_core::{game_type::GameType, resource_location::ResourceLocation}; +use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable}; +use azalea_core::resource_location::ResourceLocation; use packet_macros::{GamePacket, McBufReadable, McBufWritable}; -use tokio::io::AsyncRead; +use std::io::Read; use uuid::Uuid; -use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable}; - #[derive(Clone, Debug, GamePacket)] pub struct ClientboundUpdateAttributesPacket { #[varint] @@ -34,13 +32,9 @@ enum Operation { MultiplyTotal = 2, } -#[async_trait] impl McBufReadable for Operation { - async fn read_into(buf: &mut R) -> Result - where - R: AsyncRead + std::marker::Unpin + std::marker::Send, - { - match buf.read_byte().await? { + fn read_into(buf: &mut impl Read) -> Result { + match buf.read_byte()? { 0 => Ok(Operation::Addition), 1 => Ok(Operation::MultiplyBase), 2 => Ok(Operation::MultiplyTotal), -- cgit v1.2.3