#[non_exhaustive]pub struct Node {
pub header: Header,
pub crc_valid: Option<bool>,
/* private fields */
}Expand description
A parsed btrfs B-tree node (leaf or interior), plus its non-fatal checksum status. The raw block bytes are retained so leaf item data can be sliced on demand (bounds-checked).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.header: HeaderThe decoded 101-byte header.
crc_valid: Option<bool>The crc32c status over [0x20 .. block.len()]: Some(true) if the
stored digest verifies, Some(false) if it does not (corrupt/tampered),
or None for a non-crc32c checksum whose verifier is deferred.
Implementations§
Source§impl Node
impl Node
Sourcepub fn parse(block: &[u8]) -> Result<Self, BtrfsError>
pub fn parse(block: &[u8]) -> Result<Self, BtrfsError>
Parse a nodesize-byte btrfs node from the start of block.
The block should be exactly one node (nodesize bytes); the checksum is
computed over [0x20 .. block.len()], so pass the whole node block. A
bad checksum does not fail the parse — it is surfaced in
Node::crc_valid.
§Errors
BtrfsError::Truncatedifblockis shorter than the 101-byte header.
Sourcepub fn leaf_items(&self) -> impl Iterator<Item = (DiskKey, &[u8])>
pub fn leaf_items(&self) -> impl Iterator<Item = (DiskKey, &[u8])>
Iterate (key, data) over a leaf’s items. Each data slice is
bounds-checked against the block: a lying data_offset/data_size
yields an empty slice, never an over-read. An interior node yields
nothing.
Sourcepub fn key_ptrs(&self) -> &[KeyPtr]
pub fn key_ptrs(&self) -> &[KeyPtr]
The interior node’s child key-pointers. A leaf yields an empty slice.
Sourcepub fn chunk_items(&self) -> Vec<(u64, Chunk)>
pub fn chunk_items(&self) -> Vec<(u64, Chunk)>
Decode every CHUNK_ITEM in a leaf into (logical_start, Chunk) pairs
(the logical start is the item key’s offset). Non-CHUNK items (e.g.
DEV_ITEM) are skipped. An interior node yields nothing.