Skip to main content

Header

Struct Header 

Source
pub struct Header {
    pub csum: [u8; 32],
    pub fsid: Uuid,
    pub bytenr: u64,
    pub flags: HeaderFlags,
    pub chunk_tree_uuid: Uuid,
    pub generation: u64,
    pub owner: u64,
    pub nritems: u32,
    pub level: u8,
}
Expand description

Parsed header of a btrfs tree block (shared by nodes and leaves).

Every tree block (node or leaf) begins with this 101-byte header. It identifies the block’s position in the tree, its owning tree, and contains a checksum covering the entire block.

Fields§

§csum: [u8; 32]

Checksum of everything past this field to the end of the tree block.

§fsid: Uuid

Filesystem UUID (must match the superblock’s fsid or metadata_uuid).

§bytenr: u64

Logical byte offset where this block is stored.

§flags: HeaderFlags

Header flags (lower 56 bits) and backref revision (upper 8 bits).

§chunk_tree_uuid: Uuid

UUID of the chunk tree that maps this block’s logical address.

§generation: u64

Transaction generation when this block was last written.

§owner: u64

Objectid of the tree that owns this block (e.g. 1 = root tree, 5 = FS tree).

§nritems: u32

Number of items (leaf) or key pointers (node) in this block.

§level: u8

Tree level: 0 for leaves, >0 for internal nodes.

Implementations§

Source§

impl Header

Source

pub fn parse(buf: &[u8]) -> Self

Parse a tree block header from the start of buf.

§Panics

Panics if buf is smaller than the on-disk header size (101 bytes).

Source

pub fn backref_rev(&self) -> u64

Return the backref revision from the flags field.

Source

pub fn block_flags(&self) -> HeaderFlags

Return the block flags with the backref revision bits masked out.

Trait Implementations§

Source§

impl Clone for Header

Source§

fn clone(&self) -> Header

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Header

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
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.