diff options
| author | mat <github@matdoes.dev> | 2022-04-24 22:46:41 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-04-24 22:46:41 -0500 |
| commit | f4dd3a9293367fa8f3d839a184e8055b22595204 (patch) | |
| tree | 3beafa3c8035c69a33b7d0f12779236bf786cf36 /azalea-protocol/src/mc_buf/read.rs | |
| parent | 4c00bd886578c70f6aeb35400d9d03b355df3155 (diff) | |
| download | azalea-drasl-f4dd3a9293367fa8f3d839a184e8055b22595204.tar.xz | |
ENCRYPTION WORKS!!!!!!!!!!!
Diffstat (limited to 'azalea-protocol/src/mc_buf/read.rs')
| -rwxr-xr-x | azalea-protocol/src/mc_buf/read.rs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/azalea-protocol/src/mc_buf/read.rs b/azalea-protocol/src/mc_buf/read.rs index 1e031916..3d50e5aa 100755 --- a/azalea-protocol/src/mc_buf/read.rs +++ b/azalea-protocol/src/mc_buf/read.rs @@ -5,6 +5,7 @@ use azalea_core::{ }; use serde::Deserialize; use tokio::io::{AsyncRead, AsyncReadExt}; +use crate::mc_buf::ByteArray; use super::MAX_STRING_LENGTH; @@ -14,7 +15,7 @@ pub trait Readable { async fn read_varint(&mut self) -> Result<i32, String>; fn get_varint_size(&mut self, value: i32) -> u8; fn get_varlong_size(&mut self, value: i32) -> u8; - async fn read_byte_array(&mut self) -> Result<Vec<u8>, String>; + async fn read_byte_array(&mut self) -> Result<ByteArray, String>; async fn read_bytes_with_len(&mut self, n: usize) -> Result<Vec<u8>, String>; async fn read_bytes(&mut self) -> Result<Vec<u8>, String>; async fn read_utf(&mut self) -> Result<String, String>; @@ -80,9 +81,9 @@ where 10 } - async fn read_byte_array(&mut self) -> Result<Vec<u8>, String> { + async fn read_byte_array(&mut self) -> Result<ByteArray, String> { let length = self.read_varint().await? as usize; - Ok(self.read_bytes_with_len(length).await?) + Ok(ByteArray(self.read_bytes_with_len(length).await?)) } async fn read_bytes_with_len(&mut self, n: usize) -> Result<Vec<u8>, String> { @@ -251,6 +252,17 @@ impl McBufReadable for Vec<u8> { } } + +#[async_trait] +impl McBufReadable for ByteArray { + async fn read_into<R>(buf: &mut R) -> Result<Self, String> + where + R: AsyncRead + std::marker::Unpin + std::marker::Send, + { + buf.read_byte_array().await + } +} + // string #[async_trait] impl McBufReadable for String { |
