diff options
| author | mat <github@matdoes.dev> | 2022-09-04 21:24:10 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-09-04 21:24:10 -0500 |
| commit | 99fcad7bc4133c32627fe2e4751faad05b9b4ef1 (patch) | |
| tree | 77d776fa1eb0476d1709c67c07af2293674c4a0e /azalea-buf/src | |
| parent | 2557d70576764c32773153d33eeaa31f34b16b15 (diff) | |
| download | azalea-drasl-99fcad7bc4133c32627fe2e4751faad05b9b4ef1.tar.xz | |
fix chunks not being able to be read
Diffstat (limited to 'azalea-buf/src')
| -rw-r--r-- | azalea-buf/src/lib.rs | 3 | ||||
| -rw-r--r-- | azalea-buf/src/read.rs | 10 |
2 files changed, 10 insertions, 3 deletions
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<Self, BufReadError> { - i32::read_from(buf).map(|i| i as u16) + i16::read_from(buf).map(|i| i as u16) } } |
