use std::mem::{offset_of, size_of};
use super::NodeType;
pub const BLOB_MAX_INLINE: usize = 104;
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct BlobNode {
pub count: u8,
pub node_type: u8,
_pad_2: [u8; 2],
pub prefix_len: u16,
_pad_6: u16,
pub child_blob_guid: [u8; 16],
pub bytes: [u8; BLOB_MAX_INLINE],
}
const _: () = assert!(size_of::<BlobNode>() == 128);
const _: () = assert!(offset_of!(BlobNode, child_blob_guid) == 8);
const _: () = assert!(offset_of!(BlobNode, bytes) == 24);
impl BlobNode {
#[must_use]
pub fn new(prefix_bytes: &[u8], child_guid: [u8; 16]) -> Self {
assert!(prefix_bytes.len() <= BLOB_MAX_INLINE);
let mut b = Self {
count: 1,
node_type: NodeType::Blob.as_u8(),
_pad_2: [0; 2],
prefix_len: prefix_bytes.len() as u16,
_pad_6: 0,
child_blob_guid: child_guid,
bytes: [0; BLOB_MAX_INLINE],
};
b.bytes[..prefix_bytes.len()].copy_from_slice(prefix_bytes);
b
}
}