Skip to main content

TablePage

Struct TablePage 

Source
pub struct TablePage { /* private fields */ }
Expand description

A table-leaf page. Owns a heap-allocated 4089-byte payload buffer.

Implementations§

Source§

impl TablePage

Source

pub fn empty() -> Self

Creates a fresh, empty page.

Source

pub fn from_bytes(bytes: &[u8; 4089]) -> Self

Rehydrates a page from its on-disk payload bytes.

Source

pub fn as_bytes(&self) -> &[u8; 4089]

Exposes the raw payload bytes for writing to the pager.

Source

pub fn slot_count(&self) -> usize

Source

pub fn cells_top(&self) -> usize

Source

pub fn free_space(&self) -> usize

Contiguous free bytes between the end of the slot directory and the top of the cell-content area.

Source

pub fn would_fit(&self, cell_encoded_size: usize) -> bool

Returns true if a cell of the given encoded size fits, accounting for the extra 2 bytes needed for a new slot entry.

Source

pub fn slot_offset_raw(&self, slot: usize) -> Result<usize>

Raw byte offset, within the payload, where the cell for slot begins. Used by readers that decode the cell body with a type other than PagedEntry — e.g., index-cell leaves carry IndexCells instead of row cells.

Source

pub fn rowid_at(&self, slot: usize) -> Result<i64>

Reads the rowid of the cell at a given slot without decoding the full cell body. Used by find to binary-search the directory.

Source

pub fn cell_at(&self, slot: usize) -> Result<Cell>

Decodes the full cell stored at slot.

Source

pub fn find(&self, rowid: i64) -> Result<Find>

Binary-search for rowid in the slot directory.

Source

pub fn lookup(&self, rowid: i64) -> Result<Option<Cell>>

Returns the cell with this rowid, or None if it’s not on the page.

Source

pub fn iter(&self) -> TablePageIter<'_>

Iterates (rowid, Cell) pairs in ascending rowid order. This is O(N × cell-decode) — only use it when you actually need the bodies.

Source

pub fn insert(&mut self, cell: &Cell) -> Result<()>

Inserts cell as a local entry in rowid order. See TablePage::insert_entry for the lower-level primitive that also accepts overflow pointers.

Source

pub fn insert_paged_entry(&mut self, entry: &PagedEntry) -> Result<()>

Inserts either kind of paged entry. Delegates to TablePage::insert_entry after encoding.

Source

pub fn insert_entry(&mut self, rowid: i64, encoded: &[u8]) -> Result<()>

Inserts pre-encoded bytes at the slot that keeps the directory in rowid order. Fails with Internal("page full") if the bytes plus a new slot wouldn’t fit, and with Internal("duplicate rowid") if a cell or overflow pointer with the same rowid already lives on the page. Callers should check would_fit(encoded.len()) first — this method asserts the fit.

Source

pub fn entry_at(&self, slot: usize) -> Result<PagedEntry>

Decodes the paged entry at slot. Either a local cell or an overflow pointer.

Source

pub fn delete(&mut self, rowid: i64) -> Result<bool>

Removes the cell with rowid. Returns Ok(true) if it was found and removed, Ok(false) if the page didn’t contain it. The cell’s bytes stay in place — only its slot is dropped.

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> 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, 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.