use std::mem::{offset_of, size_of};
pub const PREFIX_MAX_INLINE: usize = 112;
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct Prefix {
pub count: u8,
pub node_type: u8,
_pad_2: [u8; 2],
pub prefix_len: u16,
_pad_6: u16,
pub child: u32,
_pad_12: u32,
pub bytes: [u8; PREFIX_MAX_INLINE],
}
const _: () = assert!(size_of::<Prefix>() == 128);
const _: () = assert!(offset_of!(Prefix, count) == 0);
const _: () = assert!(offset_of!(Prefix, node_type) == 1);
const _: () = assert!(offset_of!(Prefix, prefix_len) == 4);
const _: () = assert!(offset_of!(Prefix, child) == 8);
const _: () = assert!(offset_of!(Prefix, bytes) == 16);
impl Prefix {
#[must_use]
pub fn new(prefix_bytes: &[u8], child_slot: u32) -> Self {
assert!(prefix_bytes.len() <= PREFIX_MAX_INLINE);
let mut p = Self {
count: 1,
node_type: super::NodeType::Prefix.as_u8(),
_pad_2: [0; 2],
prefix_len: prefix_bytes.len() as u16,
_pad_6: 0,
child: child_slot,
_pad_12: 0,
bytes: [0; PREFIX_MAX_INLINE],
};
p.bytes[..prefix_bytes.len()].copy_from_slice(prefix_bytes);
p
}
}