diff options
| author | mat <github@matdoes.dev> | 2022-06-23 19:17:04 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-06-23 19:17:04 -0500 |
| commit | 37c6618c16319a7f40fd2e165190407472598e84 (patch) | |
| tree | 6d712df8893041f0e49cfa6ca7adc9a411d39b84 /azalea-buf/src/definitions.rs | |
| parent | 1089aa7961bd9af67c94dec9c5dbc6bd9f275225 (diff) | |
| download | azalea-drasl-37c6618c16319a7f40fd2e165190407472598e84.tar.xz | |
Fix everything so azalea-buf works
Diffstat (limited to 'azalea-buf/src/definitions.rs')
| -rw-r--r-- | azalea-buf/src/definitions.rs | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/azalea-buf/src/definitions.rs b/azalea-buf/src/definitions.rs index e5d8e0c0..921fb63d 100644 --- a/azalea-buf/src/definitions.rs +++ b/azalea-buf/src/definitions.rs @@ -1,5 +1,8 @@ -use buf_macros::McBuf; -use std::ops::Deref; +use crate::{McBufReadable, McBufWritable}; +use std::{ + io::{Read, Write}, + ops::Deref, +}; /// A Vec<u8> that isn't prefixed by a VarInt with the size. #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -26,7 +29,7 @@ impl From<&str> for UnsizedByteArray { } /// Represents Java's BitSet, a list of bits. -#[derive(Debug, Clone, PartialEq, Eq, Hash, McBuf)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct BitSet { data: Vec<u64>, } @@ -37,3 +40,17 @@ impl BitSet { (self.data[index / 64] & (1u64 << (index % 64))) != 0 } } + +impl McBufReadable for BitSet { + fn read_into(buf: &mut impl Read) -> Result<Self, String> { + Ok(Self { + data: Vec::<u64>::read_into(buf)?, + }) + } +} + +impl McBufWritable for BitSet { + fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + self.data.write_into(buf) + } +} |
