Skip to main content

Storage

Struct Storage 

Source
pub struct Storage { /* private fields */ }

Implementations§

Source§

impl Storage

Source

pub fn create(path: &Path) -> Result<Self, MqdbError>

Create a new empty database file. Writes file header + empty catalog.

Source

pub fn open(path: &Path) -> Result<Self, MqdbError>

Open an existing database file. Validates magic + version.

Source

pub fn write_document(&mut self, doc: &Document) -> Result<u32, MqdbError>

Write one document’s blocks to the page file. Returns the first_block_page.

Source

pub fn read_blocks( &mut self, first_page: u32, num_blocks: u32, ) -> Result<Vec<Block>, MqdbError>

Read all blocks for a document given its first_block_page and num_blocks.

Source

pub fn flush_catalog( &mut self, entries: &[CatalogEntry], custom_tables: &[CustomTableEntry], ) -> Result<(), MqdbError>

Save catalog (call after all write_document calls).

Source

pub fn load_catalog( &mut self, ) -> Result<(Vec<CatalogEntry>, Vec<CustomTableEntry>), MqdbError>

Read the catalog.

Source

pub fn write_index(&mut self, bytes: &[u8]) -> Result<u32, MqdbError>

Write raw index bytes as a chained page sequence. Returns the first page id.

Source

pub fn read_index_bytes( &mut self, first_page: u32, ) -> Result<Vec<u8>, MqdbError>

Read all bytes from an index page chain starting at first_page.

Source

pub fn write_table_rows( &mut self, rows: &[Vec<String>], ) -> Result<(u32, u32), MqdbError>

Write a fresh chain of table-row pages, starting a brand-new table. Returns (first_page, last_page), or (0, 0) if rows is empty (nothing written — 0 is never a valid page id).

Source

pub fn append_table_rows( &mut self, tail_page: u32, rows: &[Vec<String>], ) -> Result<u32, MqdbError>

Append rows after an existing table-row chain by writing new pages and relinking the current tail (tail_page) to point at them. Returns the new tail page id (unchanged if rows is empty).

Source

pub fn read_table_rows( &mut self, first_page: u32, num_rows: u32, num_cols: usize, ) -> Result<Vec<Vec<String>>, MqdbError>

Read all rows for a table given its chain head, row count, and column count.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V