use {
crate::{constants::CSUM_SIZE, Key, UuidBytes},
byteorder::LE,
num_enum::{IntoPrimitive, TryFromPrimitive},
static_assertions::const_assert_eq,
strum::EnumIter,
zerocopy::{AsBytes, FromBytes, Unaligned, U32, U64},
};
#[derive(Clone, Debug, AsBytes, FromBytes, Unaligned)]
#[repr(C, packed)]
pub struct Header {
pub csum: [u8; CSUM_SIZE],
pub fs_uuid: UuidBytes,
pub logical_address: U64<LE>,
pub flags: [u8; 7],
pub backref_rev: u8,
pub chunk_tree_uuid: UuidBytes,
pub generation: U64<LE>,
pub tree_id: U64<LE>,
pub num_items: U32<LE>,
pub level: u8,
}
const_assert_eq!(std::mem::size_of::<Header>(), 101);
#[derive(Copy, Clone, Debug, AsBytes, FromBytes, Unaligned)]
#[repr(C, packed)]
pub struct KeyPointer {
pub key: Key,
pub block_pointer: U64<LE>,
pub generation: U64<LE>,
}
const_assert_eq!(std::mem::size_of::<KeyPointer>(), 33);
#[derive(Copy, Clone, Debug, AsBytes, FromBytes, Unaligned)]
#[repr(C, packed)]
pub struct Item {
pub key: Key,
pub offset: U32<LE>,
pub size: U32<LE>,
}
const_assert_eq!(std::mem::size_of::<Item>(), 25);
#[derive(Copy, Clone, Debug, Hash, PartialEq, EnumIter, IntoPrimitive, TryFromPrimitive)]
#[repr(u8)]
pub enum BackrefRevision {
Old = 0,
Mixed = 1,
}