use std::mem::{offset_of, size_of};
pub const PAGE_SIZE: u32 = 0x80000;
pub const HEADER_SIZE: u32 = 0x1000;
pub const MAX_SLOTS: u32 = 0x2800;
pub const SLOT_TABLE_SIZE: u32 = MAX_SLOTS * 4;
pub const DATA_AREA_START: u32 = HEADER_SIZE + SLOT_TABLE_SIZE;
const _: () = assert!(DATA_AREA_START == 0xB000);
pub type BlobGuid = [u8; 16];
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct BlobHeader {
_pad_0: [u8; 0x50],
pub field_50: u16,
pub field_52: u16,
pub num_slots: u16,
pub root_slot: u16,
pub space_used: u32,
pub num_ext_blobs: u16,
pub field_5e: u16,
pub compact_times: u32,
_pad_64: [u8; 4],
pub gap_space: u32,
pub tombstone_leaf_cnt: u32,
pub free_list_head: [u16; 8],
_pad_80: [u8; 0x20],
pub blob_guid: BlobGuid,
_pad_b0: [u8; (HEADER_SIZE as usize) - 0xb0],
}
const _: () = assert!(size_of::<BlobHeader>() == HEADER_SIZE as usize);
const _: () = assert!(offset_of!(BlobHeader, field_50) == 0x50);
const _: () = assert!(offset_of!(BlobHeader, num_slots) == 0x54);
const _: () = assert!(offset_of!(BlobHeader, root_slot) == 0x56);
const _: () = assert!(offset_of!(BlobHeader, space_used) == 0x58);
const _: () = assert!(offset_of!(BlobHeader, num_ext_blobs) == 0x5c);
const _: () = assert!(offset_of!(BlobHeader, compact_times) == 0x60);
const _: () = assert!(offset_of!(BlobHeader, gap_space) == 0x68);
const _: () = assert!(offset_of!(BlobHeader, tombstone_leaf_cnt) == 0x6c);
const _: () = assert!(offset_of!(BlobHeader, free_list_head) == 0x70);
const _: () = assert!(offset_of!(BlobHeader, blob_guid) == 0xa0);
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn header_size_and_offsets() {
assert_eq!(size_of::<BlobHeader>(), 4096);
assert_eq!(offset_of!(BlobHeader, num_slots), 0x54);
assert_eq!(offset_of!(BlobHeader, root_slot), 0x56);
assert_eq!(offset_of!(BlobHeader, space_used), 0x58);
assert_eq!(offset_of!(BlobHeader, compact_times), 0x60);
assert_eq!(offset_of!(BlobHeader, gap_space), 0x68);
assert_eq!(offset_of!(BlobHeader, tombstone_leaf_cnt), 0x6c);
assert_eq!(offset_of!(BlobHeader, free_list_head), 0x70);
assert_eq!(offset_of!(BlobHeader, blob_guid), 0xa0);
}
#[test]
fn constants_consistent() {
assert_eq!(PAGE_SIZE, 524_288);
assert_eq!(HEADER_SIZE, 4096);
assert_eq!(MAX_SLOTS, 10_240);
assert_eq!(DATA_AREA_START, 0xB000);
}
}