pub struct Storage { /* private fields */ }Implementations§
Source§impl Storage
impl Storage
Sourcepub fn create(path: &Path) -> Result<Self, MqdbError>
pub fn create(path: &Path) -> Result<Self, MqdbError>
Create a new empty database file. Writes file header + empty catalog.
Sourcepub fn open(path: &Path) -> Result<Self, MqdbError>
pub fn open(path: &Path) -> Result<Self, MqdbError>
Open an existing database file. Validates magic + version.
Sourcepub fn write_document(&mut self, doc: &Document) -> Result<u32, MqdbError>
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.
Sourcepub fn read_blocks(
&mut self,
first_page: u32,
num_blocks: u32,
) -> Result<Vec<Block>, MqdbError>
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.
Sourcepub fn flush_catalog(
&mut self,
entries: &[CatalogEntry],
custom_tables: &[CustomTableEntry],
) -> Result<(), MqdbError>
pub fn flush_catalog( &mut self, entries: &[CatalogEntry], custom_tables: &[CustomTableEntry], ) -> Result<(), MqdbError>
Save catalog (call after all write_document calls).
Sourcepub fn load_catalog(
&mut self,
) -> Result<(Vec<CatalogEntry>, Vec<CustomTableEntry>), MqdbError>
pub fn load_catalog( &mut self, ) -> Result<(Vec<CatalogEntry>, Vec<CustomTableEntry>), MqdbError>
Read the catalog.
Sourcepub fn write_index(&mut self, bytes: &[u8]) -> Result<u32, MqdbError>
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.
Sourcepub fn read_index_bytes(
&mut self,
first_page: u32,
) -> Result<Vec<u8>, MqdbError>
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.
Sourcepub fn write_table_rows(
&mut self,
rows: &[Vec<String>],
) -> Result<(u32, u32), MqdbError>
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).
Auto Trait Implementations§
impl Freeze for Storage
impl RefUnwindSafe for Storage
impl Send for Storage
impl Sync for Storage
impl Unpin for Storage
impl UnsafeUnpin for Storage
impl UnwindSafe for Storage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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