pub struct Database { /* private fields */ }Expand description
A cloneable handle to an embedded Basalt database.
Implementations§
Source§impl Database
impl Database
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Database, DbError>
pub fn open(path: impl AsRef<Path>) -> Result<Database, DbError>
Open or create a durable database at path.
Sourcepub fn begin(&self) -> Result<Transaction, DbError>
pub fn begin(&self) -> Result<Transaction, DbError>
Begin an optimistic snapshot transaction.
Sourcepub fn transaction(&self) -> Result<Transaction, DbError>
pub fn transaction(&self) -> Result<Transaction, DbError>
Alias for Database::begin using the conventional transaction name.
Sourcepub fn connect(&self) -> Connection
pub fn connect(&self) -> Connection
Create a stateful connection. Connections are useful when SQL
BEGIN, COMMIT, and ROLLBACK statements span multiple calls.
Sourcepub fn execute(&self, stmt: &Statement) -> Result<StatementResult, DbError>
pub fn execute(&self, stmt: &Statement) -> Result<StatementResult, DbError>
Execute one statement as an autocommit operation.
Sourcepub fn execute_sql(&self, sql: &str) -> Result<Vec<StatementResult>, DbError>
pub fn execute_sql(&self, sql: &str) -> Result<Vec<StatementResult>, DbError>
Parse and execute all statements through a fresh autocommit connection.
Sourcepub fn checkpoint(&self) -> Result<(), DbError>
pub fn checkpoint(&self) -> Result<(), DbError>
Flush the current state into the page file and clear committed WAL frames. Checkpointing is safe while readers are active.
Sourcepub fn generation(&self) -> u64
pub fn generation(&self) -> u64
Current committed generation, useful for diagnostics and tests.
Sourcepub fn table_names(&self) -> Result<Vec<String>, DbError>
pub fn table_names(&self) -> Result<Vec<String>, DbError>
Return table names in deterministic order for schema discovery tools.
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