1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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!(core::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!(core::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!(core::mem::size_of::<Item>(), 25);
#[derive(Copy, Clone, Debug, Hash, PartialEq, EnumIter, IntoPrimitive, TryFromPrimitive)]
#[repr(u8)]
pub enum BackrefRevision {
Old = 0,
Mixed = 1,
}