pub struct Database { /* private fields */ }Expand description
RedDB Database Engine
The main entry point for database operations. Thread-safe.
Implementations§
Source§impl Database
impl Database
Sourcepub fn open<P>(path: P) -> Result<Database, DatabaseError>
pub fn open<P>(path: P) -> Result<Database, DatabaseError>
Open or create a database
Sourcepub fn bgwriter_stats(&self) -> Option<BgWriterStatsSnapshot>
pub fn bgwriter_stats(&self) -> Option<BgWriterStatsSnapshot>
Background-writer stats snapshot — None when the writer
isn’t running (read-only mode, or spawn skipped). Exposed for
tests + introspection.
Sourcepub fn open_with_config<P>(
path: P,
config: DatabaseConfig,
) -> Result<Database, DatabaseError>
pub fn open_with_config<P>( path: P, config: DatabaseConfig, ) -> Result<Database, DatabaseError>
Open or create a database with custom configuration
Sourcepub fn begin(&self) -> Result<Transaction, DatabaseError>
pub fn begin(&self) -> Result<Transaction, DatabaseError>
Begin a new transaction
Sourcepub fn tx_manager(&self) -> &Arc<TransactionManager> ⓘ
pub fn tx_manager(&self) -> &Arc<TransactionManager> ⓘ
Get a reference to the transaction manager
Sourcepub fn allocate_page(&self, page_type: PageType) -> Result<Page, DatabaseError>
pub fn allocate_page(&self, page_type: PageType) -> Result<Page, DatabaseError>
Allocate a new page
Sourcepub fn checkpoint(&self) -> Result<CheckpointResult, DatabaseError>
pub fn checkpoint(&self) -> Result<CheckpointResult, DatabaseError>
Perform a checkpoint
Sourcepub fn maybe_auto_checkpoint(
&self,
) -> Result<Option<CheckpointResult>, DatabaseError>
pub fn maybe_auto_checkpoint( &self, ) -> Result<Option<CheckpointResult>, DatabaseError>
Check if auto-checkpoint is needed and perform it
Sourcepub fn increment_page_count(&self, count: u32)
pub fn increment_page_count(&self, count: u32)
Increment pages-since-checkpoint counter
Sourcepub fn sync(&self) -> Result<(), DatabaseError>
pub fn sync(&self) -> Result<(), DatabaseError>
Sync all data to disk
Sourcepub fn close(self) -> Result<(), DatabaseError>
pub fn close(self) -> Result<(), DatabaseError>
Close the database
Performs a final checkpoint and syncs all data to disk.
Sourcepub fn is_read_only(&self) -> bool
pub fn is_read_only(&self) -> bool
Check if database is read-only
Sourcepub fn page_count(&self) -> u32
pub fn page_count(&self) -> u32
Get page count
Sourcepub fn file_size(&self) -> Result<u64, DatabaseError>
pub fn file_size(&self) -> Result<u64, DatabaseError>
Get database file size
Sourcepub fn cache_stats(&self) -> CacheStats
pub fn cache_stats(&self) -> CacheStats
Get cache statistics
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 UnsafeUnpin 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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request