diff options
| author | mat <github@matdoes.dev> | 2022-05-05 22:12:54 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-05-05 22:12:54 -0500 |
| commit | 4dac004635e50682d9ebe8812fdf654a0c1808f1 (patch) | |
| tree | 46257a144ec069ba3e0a812eabca6e9ed246db6b /azalea-protocol/src/mc_buf/read.rs | |
| parent | 57b76ef52b7a9b516710aea5ba5d6f0141c8d6cf (diff) | |
| download | azalea-drasl-4dac004635e50682d9ebe8812fdf654a0c1808f1.tar.xz | |
Fix chunk decoding
Diffstat (limited to 'azalea-protocol/src/mc_buf/read.rs')
| -rwxr-xr-x | azalea-protocol/src/mc_buf/read.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/azalea-protocol/src/mc_buf/read.rs b/azalea-protocol/src/mc_buf/read.rs index e1ae321c..a8c44bdf 100755 --- a/azalea-protocol/src/mc_buf/read.rs +++ b/azalea-protocol/src/mc_buf/read.rs @@ -255,6 +255,17 @@ impl McBufVarintReadable for i32 { } } +impl<T: McBufVarintReadable> McBufVarintReadable for Vec<T> { + fn varint_read_into(buf: &mut impl Read) -> Result<Self, String> { + let length = u32::varint_read_into(buf)?; + let mut vec = Vec::with_capacity(length as usize); + for _ in 0..length { + vec.push(T::varint_read_into(buf)?); + } + Ok(vec) + } +} + impl McBufReadable for UnsizedByteArray { fn read_into(buf: &mut impl Read) -> Result<Self, String> { Ok(UnsizedByteArray(buf.read_bytes()?)) |
