From cfb190d00c70f1b09789e23f89a3c67840e0fd87 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Fri, 2 Sep 2022 12:11:14 -0500 Subject: get rid of Readable & Writable (#21) --- azalea-protocol/src/write.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'azalea-protocol/src/write.rs') diff --git a/azalea-protocol/src/write.rs b/azalea-protocol/src/write.rs index 30710f8b..b2ae2810 100755 --- a/azalea-protocol/src/write.rs +++ b/azalea-protocol/src/write.rs @@ -1,6 +1,6 @@ use crate::{packets::ProtocolPacket, read::MAXIMUM_UNCOMPRESSED_LENGTH}; use async_compression::tokio::bufread::ZlibEncoder; -use azalea_buf::Writable; +use azalea_buf::McBufVarWritable; use azalea_crypto::Aes128CfbEnc; use std::fmt::Debug; use thiserror::Error; @@ -8,7 +8,7 @@ use tokio::io::{AsyncReadExt, AsyncWrite, AsyncWriteExt}; fn frame_prepender(data: &mut Vec) -> Result, std::io::Error> { let mut buf = Vec::new(); - buf.write_varint(data.len() as i32)?; + (data.len() as u32).var_write_into(&mut buf)?; buf.append(data); Ok(buf) } @@ -29,7 +29,7 @@ fn packet_encoder( packet: &P, ) -> Result, PacketEncodeError> { let mut buf = Vec::new(); - buf.write_varint(packet.id() as i32)?; + (packet.id() as u32).var_write_into(&mut buf)?; packet.write(&mut buf)?; if buf.len() > MAXIMUM_UNCOMPRESSED_LENGTH as usize { return Err(PacketEncodeError::TooBig { @@ -55,7 +55,7 @@ async fn compression_encoder( // if it's less than the compression threshold, don't compress if n < compression_threshold as usize { let mut buf = Vec::new(); - buf.write_varint(0)?; + 0.var_write_into(&mut buf)?; buf.write_all(data).await?; Ok(buf) } else { -- cgit v1.2.3