diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2022-05-07 23:38:16 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-07 23:38:16 +0000 |
| commit | d9e388d8b0d8b3bdcf7a2e21b0cd2daa78d295e7 (patch) | |
| tree | 8165f83b45e06c17d9114f1672ac73f202ba4b68 /azalea-protocol/src/mc_buf/mod.rs | |
| parent | 71acb5b3363fe8a7a9ac09691de01d7342db3ad1 (diff) | |
| parent | f198bdf777d4c68b11e6aeabeb96b5035e1ec5e1 (diff) | |
| download | azalea-drasl-d9e388d8b0d8b3bdcf7a2e21b0cd2daa78d295e7.tar.xz | |
Merge pull request #5 from mat-1/code-gen
Code gen
Diffstat (limited to 'azalea-protocol/src/mc_buf/mod.rs')
| -rwxr-xr-x | azalea-protocol/src/mc_buf/mod.rs | 39 |
1 files changed, 2 insertions, 37 deletions
diff --git a/azalea-protocol/src/mc_buf/mod.rs b/azalea-protocol/src/mc_buf/mod.rs index 1626d163..bee269c9 100755 --- a/azalea-protocol/src/mc_buf/mod.rs +++ b/azalea-protocol/src/mc_buf/mod.rs @@ -1,8 +1,10 @@ //! Utilities for reading and writing for the Minecraft protocol +mod definitions; mod read; mod write; +pub use definitions::{BitSet, EntityMetadata, UnsizedByteArray}; use packet_macros::{McBufReadable, McBufWritable}; pub use read::{read_varint_async, McBufReadable, McBufVarReadable, Readable}; use std::ops::Deref; @@ -14,43 +16,6 @@ const MAX_STRING_LENGTH: u16 = 32767; // TODO: have a definitions.rs in mc_buf that contains UnsizedByteArray and BitSet -/// A Vec<u8> that isn't prefixed by a VarInt with the size. -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct UnsizedByteArray(Vec<u8>); - -impl Deref for UnsizedByteArray { - type Target = Vec<u8>; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl From<Vec<u8>> for UnsizedByteArray { - fn from(vec: Vec<u8>) -> Self { - Self(vec) - } -} - -impl From<&str> for UnsizedByteArray { - fn from(s: &str) -> Self { - Self(s.as_bytes().to_vec()) - } -} - -/// Represents Java's BitSet, a list of bits. -#[derive(Debug, Clone, PartialEq, Eq, Hash, McBufReadable, McBufWritable)] -pub struct BitSet { - data: Vec<u64>, -} - -// the Index trait requires us to return a reference, but we can't do that -impl BitSet { - pub fn index(&self, index: usize) -> bool { - (self.data[index / 64] & (1u64 << (index % 64))) != 0 - } -} - #[cfg(test)] mod tests { use super::*; |
