pub struct TablePage { /* private fields */ }Expand description
A table-leaf page. Owns a heap-allocated 4089-byte payload buffer.
Implementations§
Source§impl TablePage
impl TablePage
Sourcepub fn from_bytes(bytes: &[u8; 4089]) -> Self
pub fn from_bytes(bytes: &[u8; 4089]) -> Self
Rehydrates a page from its on-disk payload bytes.
pub fn slot_count(&self) -> usize
pub fn cells_top(&self) -> usize
Sourcepub fn free_space(&self) -> usize
pub fn free_space(&self) -> usize
Contiguous free bytes between the end of the slot directory and the top of the cell-content area.
Sourcepub fn would_fit(&self, cell_encoded_size: usize) -> bool
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.
Sourcepub fn slot_offset_raw(&self, slot: usize) -> Result<usize>
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.
Sourcepub fn rowid_at(&self, slot: usize) -> Result<i64>
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.
Sourcepub fn lookup(&self, rowid: i64) -> Result<Option<Cell>>
pub fn lookup(&self, rowid: i64) -> Result<Option<Cell>>
Returns the cell with this rowid, or None if it’s not on the page.
Sourcepub fn iter(&self) -> TablePageIter<'_> ⓘ
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.
Sourcepub fn insert(&mut self, cell: &Cell) -> Result<()>
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.
Sourcepub fn insert_paged_entry(&mut self, entry: &PagedEntry) -> Result<()>
pub fn insert_paged_entry(&mut self, entry: &PagedEntry) -> Result<()>
Inserts either kind of paged entry. Delegates to
TablePage::insert_entry after encoding.
Sourcepub fn insert_entry(&mut self, rowid: i64, encoded: &[u8]) -> Result<()>
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.
Sourcepub fn entry_at(&self, slot: usize) -> Result<PagedEntry>
pub fn entry_at(&self, slot: usize) -> Result<PagedEntry>
Decodes the paged entry at slot. Either a local cell or an
overflow pointer.