From bc3aa9467ae1e2d0ea1727093af9b0af14965e69 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Fri, 7 Oct 2022 20:12:36 -0500 Subject: Replace impl Read with Cursor<&[u8]> (#26) * Start getting rid of Cursor * try to make the tests pass and fail * make the tests pass * remove unused uses * fix clippy warnings * fix potential OOM exploits * fix OOM in az-nbt * fix nbt benchmark * fix a test * start replacing it with Cursor> * wip * fix all the issues * fix all tests * fix nbt benchmark * fix warnings --- azalea-protocol/src/packets/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'azalea-protocol/src/packets/mod.rs') diff --git a/azalea-protocol/src/packets/mod.rs b/azalea-protocol/src/packets/mod.rs index 110929a1..f7270b51 100644 --- a/azalea-protocol/src/packets/mod.rs +++ b/azalea-protocol/src/packets/mod.rs @@ -5,7 +5,7 @@ pub mod status; use crate::read::ReadPacketError; use azalea_buf::{BufReadError, McBufVarReadable, McBufVarWritable, McBufWritable}; -use std::io::{Read, Write}; +use std::io::{Cursor, Write}; // TODO: rename the packet files to just like clientbound_add_entity instead of clientbound_add_entity_packet @@ -39,13 +39,13 @@ where fn id(&self) -> u32; /// Read a packet by its id, ConnectionProtocol, and flow - fn read(id: u32, buf: &mut impl Read) -> Result; + fn read(id: u32, buf: &mut Cursor<&[u8]>) -> Result; fn write(&self, buf: &mut impl Write) -> Result<(), std::io::Error>; } impl azalea_buf::McBufReadable for ConnectionProtocol { - fn read_from(buf: &mut impl Read) -> Result { + fn read_from(buf: &mut Cursor<&[u8]>) -> Result { let id = i32::var_read_from(buf)?; ConnectionProtocol::from_i32(id).ok_or(BufReadError::UnexpectedEnumVariant { id }) } -- cgit v1.2.3