azalea_buf/definitions.rs
1use std::ops::Deref;
2
3/// A `Vec<u8>` that isn't prefixed by a VarInt with the size.
4#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5pub struct UnsizedByteArray(pub Vec<u8>);
6
7impl Deref for UnsizedByteArray {
8 type Target = [u8];
9
10 fn deref(&self) -> &Self::Target {
11 &self.0
12 }
13}
14
15impl From<Vec<u8>> for UnsizedByteArray {
16 fn from(vec: Vec<u8>) -> Self {
17 Self(vec)
18 }
19}
20
21impl From<&str> for UnsizedByteArray {
22 fn from(s: &str) -> Self {
23 Self(s.as_bytes().to_vec())
24 }
25}