mclib/nbt/tags/
byte.rs

1use crate::nbt::tags::base::{IntoNBTTag, NBTTag};
2use crate::utils::TcpUtils;
3use std::io::Read;
4
5#[derive(Debug)]
6pub struct TagByte(i8);
7
8impl IntoNBTTag for i8 {
9    fn to_nbt(self) -> Box<dyn NBTTag> {
10        Box::new(TagByte(self))
11    }
12}
13
14impl NBTTag for TagByte {
15    fn ty_id(&self) -> u8 {
16        0x01
17    }
18
19    fn pack(&self) -> Vec<u8> {
20        vec![self.0 as u8]
21    }
22
23    fn unpack(src: &mut dyn Read) -> Self {
24        Self(src.read_byte() as i8)
25    }
26}