Skip to main content

Node

Struct Node 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§header: Header

The 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

Source

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
Source

pub fn is_leaf(&self) -> bool

true if this is a leaf node (level == 0).

Source

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.

Source

pub fn key_ptrs(&self) -> &[KeyPtr]

The interior node’s child key-pointers. A leaf yields an empty slice.

Source

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.

Trait Implementations§

Source§

impl Clone for Node

Source§

fn clone(&self) -> Node

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Node

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Node

Source§

impl PartialEq for Node

Source§

fn eq(&self, other: &Node) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Node

Auto Trait Implementations§

§

impl Freeze for Node

§

impl RefUnwindSafe for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnsafeUnpin for Node

§

impl UnwindSafe for Node

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.