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.
Accepts both the current file format and older, still-recognised
versions (see page::LEGACY_VERSIONS) — check Storage::file_version
to tell which one was actually read.
Sourcepub fn file_version(&self) -> u32
pub fn file_version(&self) -> u32
The file-format version this store was read from. page::FILE_VERSION
for stores created by this build; an older value for a legacy file
that was opened for read/migration.
Sourcepub fn num_pages(&self) -> u32
pub fn num_pages(&self) -> u32
Total pages in the file, including the header and catalog pages.
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],
content_hashes: &[(u32, u64)],
views: &[ViewEntry],
) -> Result<(), MqdbError>
pub fn flush_catalog( &mut self, entries: &[CatalogEntry], custom_tables: &[CustomTableEntry], content_hashes: &[(u32, u64)], views: &[ViewEntry], ) -> Result<(), MqdbError>
Save catalog (call after all write_document calls).
Sourcepub fn load_catalog(&mut self) -> Result<CatalogData, MqdbError>
pub fn load_catalog(&mut self) -> Result<CatalogData, 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
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> ⓘ
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> ⓘ
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