Skip to main content

BTreeKeyFormat

Struct BTreeKeyFormat 

Source
pub struct BTreeKeyFormat {
    pub big_keys: bool,
    pub variable_index_keys: bool,
    pub max_key_len: u16,
}
Expand description

Describes how a B-tree encodes its keys, so the shared split / grow / rotate machinery below can serve both the classic-HFS 1-byte-key catalog and the HFS+ 2-byte (“big key”) trees without forking the algorithm.

The classic path threads BTreeKeyFormat::CLASSIC_CATALOG and is byte-identical to the pre-descriptor code (the fixed 0x25 index key produced by normalize_catalog_index_key); HFS+ threads the matching HFSPLUS_* constant, which is what unlocks variable-length index keys so an HFS+ catalog can split past a single leaf level without corrupting.

Derived from the BTHeaderRec attributes bitfield + maxKeyLength.

Fields§

§big_keys: bool

kBTBigKeysMask: key-length prefix is 2 bytes (HFS+) vs 1 byte (classic).

§variable_index_keys: bool

kBTVariableIndexKeysMask: index records store the child’s variable-length key verbatim. When clear, index keys are padded to max_key_len.

§max_key_len: u16

Maximum key length — the fixed index-key width when variable_index_keys is clear (classic catalog: 0x25; HFS+ extents-overflow: 10).

Implementations§

Source§

impl BTreeKeyFormat

Source

pub const CLASSIC_CATALOG: BTreeKeyFormat

Classic HFS catalog: 1-byte key length, fixed 0x25-byte index keys.

Source

pub const HFSPLUS_CATALOG: BTreeKeyFormat

HFS+/HFSX catalog: 2-byte key length, variable-length index keys (kHFSPlusCatalogKeyMaximumLength = 516).

Source

pub const HFSPLUS_EXTENTS: BTreeKeyFormat

HFS+ extents-overflow: 2-byte key length, fixed 10-byte index keys (kHFSPlusExtentKeyMaximumLength = 10).

Source

pub const HFSPLUS_ATTRIBUTES: BTreeKeyFormat

HFS+ attributes: 2-byte key length, variable-length index keys (kHFSPlusAttrKeyMaximumLength = 264).

Source

pub const CLASSIC_EXTENTS: BTreeKeyFormat

Classic HFS extents-overflow: 1-byte key length, fixed 7-byte keys.

Source

pub fn from_header(attributes: u32, max_key_len: u16) -> Self

Build a descriptor from a BTHeaderRec attributes bitfield and maxKeyLength. The attributes field on hand-built volumes can be 0 (no flags) even for HFS+ trees, so callers that know the tree’s identity should prefer the HFSPLUS_* / CLASSIC_CATALOG constants; this helper is for code paths that only have the raw header bytes.

Source

pub fn header_attributes(&self) -> u32

The BTHeaderRec attributes bits implied by this format.

Source

pub fn len_prefix(&self) -> usize

Bytes occupied by the key-length prefix (1 classic, 2 big-key).

Source

pub fn key_len(&self, record: &[u8]) -> usize

Read the key length stored at the front of record.

Source

pub fn key_portion(&self, record: &[u8]) -> Vec<u8> ⓘ

The key portion of a record — the length prefix plus key_len key bytes. This is exactly the slice an index separator must carry, and what the split helpers extract from a leaf/child’s first record.

Source

pub fn make_index_key(&self, first_key: &[u8]) -> Vec<u8> ⓘ

Build the key bytes of an index record (length prefix + key) from a child node’s first-key portion.

  • Classic HFS: the fixed 0x25 normalized key, identical to normalize_catalog_index_key.
  • HFS+ variable-index-key trees (catalog, attributes): the key portion verbatim (2-byte length + key bytes).
  • HFS+ fixed-index-key trees (extents-overflow): the key bytes padded to max_key_len, length field forced to max_key_len.

Trait Implementations§

Source§

impl Clone for BTreeKeyFormat

Source§

fn clone(&self) -> Self

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 Copy for BTreeKeyFormat

Source§

impl Debug for BTreeKeyFormat

Source§

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

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

impl Eq for BTreeKeyFormat

Source§

impl PartialEq for BTreeKeyFormat

Source§

fn eq(&self, other: &Self) -> 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 BTreeKeyFormat

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.