use crate::U32BigEndian;
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq, Eq)]
pub(crate) struct StructureBlock(U32BigEndian);
impl StructureBlock {
pub const LEN: usize = core::mem::size_of::<Self>();
pub const EMPTY_STR: Self = Self(U32BigEndian::from_u32(0));
pub const NODE_BEGIN: Self = Self(U32BigEndian::from_u32(1));
pub const NODE_END: Self = Self(U32BigEndian::from_u32(2));
pub const PROP: Self = Self(U32BigEndian::from_u32(3));
pub const NOP: Self = Self(U32BigEndian::from_u32(4));
pub const END: Self = Self(U32BigEndian::from_u32(9));
pub const fn into_u32(self) -> u32 {
self.0.into_u32()
}
pub const fn is_end_of_str(&self) -> bool {
matches!(self.0 .0.to_ne_bytes(), [_, _, _, 0])
}
pub const fn str_tail_zero(&self) -> usize {
match self.0 .0.to_ne_bytes() {
[0, _, _, _] => 4,
[_, 0, _, _] => 3,
[_, _, 0, _] => 2,
[_, _, _, _] => 1,
}
}
}