pub struct Database(/* private fields */);Expand description
Memory-mapped database with dynamic space allocation and hole punching.
Provides efficient storage through memory mapping with automatic region management, space reclamation via hole punching, and dynamic file growth as needed.
Implementations§
Source§impl Database
impl Database
Sourcepub fn open_with_min_len(path: &Path, min_len: u64) -> Result<Self>
pub fn open_with_min_len(path: &Path, min_len: u64) -> Result<Self>
Opens or creates a database with a minimum initial file size.
pub fn file_len(&self) -> Result<u64>
pub fn set_min_len(&self, len: u64) -> Result<()>
pub fn set_min_regions(&self, regions: usize) -> Result<()>
Sourcepub fn get_region(&self, id: &str) -> Option<Region>
pub fn get_region(&self, id: &str) -> Option<Region>
Gets an existing region by ID.
Sourcepub fn create_region_if_needed(&self, id: &str) -> Result<Region>
pub fn create_region_if_needed(&self, id: &str) -> Result<Region>
Creates a region with the given ID, or returns it if it already exists.
pub fn write_all_to_region(&self, region: &Region, data: &[u8]) -> Result<()>
pub fn write_all_to_region_at( &self, region: &Region, data: &[u8], at: u64, ) -> Result<()>
pub fn truncate_write_all_to_region( &self, region: &Region, at: u64, data: &[u8], ) -> Result<()>
Sourcepub fn truncate_region(&self, region: &Region, from: u64) -> Result<()>
pub fn truncate_region(&self, region: &Region, from: u64) -> Result<()>
From relative to start
Non destructive
pub fn remove_region_with_id(&self, id: &str) -> Result<Option<Region>>
pub fn remove_region(&self, region: Region) -> Result<Option<Region>>
pub fn retain_regions(&self, ids: HashSet<String>) -> Result<()>
pub fn mmap(&self) -> RwLockReadGuard<'_, MmapMut>
pub fn regions(&self) -> RwLockReadGuard<'_, Regions>
pub fn layout(&self) -> RwLockReadGuard<'_, Layout>
Sourcepub fn open_read_only_file(&self) -> Result<File>
pub fn open_read_only_file(&self) -> Result<File>
Open a dedicated file handle for sequential reading This enables optimal kernel readahead for iteration
pub fn disk_usage(&self) -> String
pub fn flush(&self) -> Result<()>
pub fn compact(&self) -> Result<()>
pub fn path(&self) -> &Path
pub fn weak_clone(&self) -> WeakDatabase
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Database
impl !RefUnwindSafe for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl !UnwindSafe for Database
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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