Skip to main content

BTreePageHeader

Struct BTreePageHeader 

Source
pub struct BTreePageHeader {
    pub header_offset: usize,
    pub page_type: BTreePageType,
    pub first_freeblock: u16,
    pub cell_count: u16,
    pub cell_content_start: u32,
    pub fragmented_free_bytes: u8,
    pub right_most_child: Option<PageNumber>,
}
Expand description

Parsed B-tree page header.

Fields§

§header_offset: usize

Offset within the page where the B-tree page header begins (0 normally, 100 for page 1).

§page_type: BTreePageType

Page type.

§first_freeblock: u16

Offset of the first freeblock in the freeblock list (0 if none).

§cell_count: u16

Number of cells on this page.

§cell_content_start: u32

Start of cell content area. A raw value of 0 decodes to 65536.

§fragmented_free_bytes: u8

Count of fragmented free bytes on this page.

§right_most_child: Option<PageNumber>

Right-most child page number for interior pages.

Implementations§

Source§

impl BTreePageHeader

Source

pub const fn header_size(self) -> usize

Size of the B-tree page header in bytes (8 for leaf, 12 for interior).

Source

pub fn parse( page: &[u8], page_size: PageSize, reserved_per_page: u8, is_page1: bool, ) -> Result<Self, BTreePageError>

Parse a B-tree page header from a page buffer.

Source

pub fn parse_cell_pointers( self, page: &[u8], page_size: PageSize, reserved_per_page: u8, ) -> Result<Vec<u16>, BTreePageError>

Parse the cell pointer array for this page.

Source

pub fn parse_freeblocks( self, page: &[u8], page_size: PageSize, reserved_per_page: u8, ) -> Result<Vec<Freeblock>, BTreePageError>

Traverse and parse the freeblock list for this page.

Source

pub fn write_empty_leaf_table( page: &mut [u8], header_offset: usize, usable_size: u32, )

Write an empty leaf-table B-tree page header into a buffer.

Sets up the 8-byte B-tree page header for an empty leaf table page (type 0x0D) with zero cells, suitable for sqlite_master or any newly created table root page.

header_offset is the byte offset of the B-tree header within the page buffer. For page 1 this must be DATABASE_HEADER_SIZE (100); for every other page it should be 0.

usable_size equals page_size − reserved_per_page. The cell content area offset is set to this value so that all usable space is available for future cell insertions.

Source

pub fn write_empty_leaf_index( page: &mut [u8], header_offset: usize, usable_size: u32, )

Initialize an empty leaf index page (type 0x0A) with zero cells, suitable for a newly created index root page.

header_offset is the byte offset of the B-tree header within the page buffer (0 for all non-page-1 pages).

usable_size equals page_size − reserved_per_page.

Trait Implementations§

Source§

impl Clone for BTreePageHeader

Source§

fn clone(&self) -> BTreePageHeader

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 BTreePageHeader

Source§

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

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

impl Hash for BTreePageHeader

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for BTreePageHeader

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for BTreePageHeader

Source§

impl Eq for BTreePageHeader

Source§

impl StructuralPartialEq for BTreePageHeader

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

Source§

fn instrument(self, _span: NoopSpan) -> Self

Instruments this future with a span (no-op when disabled).
Source§

fn in_current_span(self) -> Self

Instruments this future with the current span (no-op when disabled).
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more