From 99fcad7bc4133c32627fe2e4751faad05b9b4ef1 Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 4 Sep 2022 21:24:10 -0500 Subject: fix chunks not being able to be read --- azalea-buf/src/lib.rs | 3 +++ azalea-buf/src/read.rs | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'azalea-buf/src') diff --git a/azalea-buf/src/lib.rs b/azalea-buf/src/lib.rs index 24392f6e..b8daa325 100644 --- a/azalea-buf/src/lib.rs +++ b/azalea-buf/src/lib.rs @@ -1,6 +1,9 @@ //! Utilities for reading and writing for the Minecraft protocol #![feature(min_specialization)] +// these two are necessary for thiserror backtraces +#![feature(error_generic_member_access)] +#![feature(provide_any)] mod definitions; mod read; diff --git a/azalea-buf/src/read.rs b/azalea-buf/src/read.rs index 82fd4f2f..4fea4b73 100644 --- a/azalea-buf/src/read.rs +++ b/azalea-buf/src/read.rs @@ -1,6 +1,6 @@ use super::{UnsizedByteArray, MAX_STRING_LENGTH}; use byteorder::{ReadBytesExt, BE}; -use std::{collections::HashMap, hash::Hash, io::Read}; +use std::{backtrace::Backtrace, collections::HashMap, hash::Hash, io::Read}; use thiserror::Error; use tokio::io::{AsyncRead, AsyncReadExt}; @@ -15,7 +15,11 @@ pub enum BufReadError { #[error("The received encoded string buffer length is longer than maximum allowed ({length} > {max_length})")] StringLengthTooLong { length: u32, max_length: u32 }, #[error("{0}")] - Io(#[from] std::io::Error), + Io( + #[from] + #[backtrace] + std::io::Error, + ), #[error("Invalid UTF-8")] InvalidUtf8, #[error("Unexpected enum variant {id}")] @@ -207,7 +211,7 @@ impl McBufVarReadable for u32 { impl McBufReadable for u16 { fn read_from(buf: &mut impl Read) -> Result { - i32::read_from(buf).map(|i| i as u16) + i16::read_from(buf).map(|i| i as u16) } } -- cgit v1.2.3