Trait lsmlite_rs::Disk
source · pub trait Diskwhere
for<'a> Self: 'a,{
type C<'a>: Cursor;
// Required methods
fn initialize(&mut self, conf: DbConf) -> Result<(), LsmErrorCode>;
fn connect(&mut self) -> Result<(), LsmErrorCode>;
fn disconnect(&mut self) -> Result<(), LsmErrorCode>;
fn persist(&mut self, key: &[u8], value: &[u8]) -> Result<(), LsmErrorCode>;
fn update(&mut self, key: &[u8], value: &[u8]) -> Result<(), LsmErrorCode>;
fn delete(&mut self, key: &[u8]) -> Result<(), LsmErrorCode>;
fn delete_range(
&mut self,
begin: &[u8],
end: &[u8]
) -> Result<(), LsmErrorCode>;
fn optimize(&mut self) -> Result<(), LsmErrorCode>;
fn begin_transaction(&mut self) -> Result<(), LsmErrorCode>;
fn commit_transaction(&mut self) -> Result<(), LsmErrorCode>;
fn rollback_transaction(&mut self) -> Result<(), LsmErrorCode>;
fn cursor_open(&self) -> Result<Self::C<'_>, LsmErrorCode>;
}
Expand description
Primary set of methods of a database.
Required Associated Types§
Required Methods§
sourcefn initialize(&mut self, conf: DbConf) -> Result<(), LsmErrorCode>
fn initialize(&mut self, conf: DbConf) -> Result<(), LsmErrorCode>
Initializes a database with a given configuration (of type DbConf
).
sourcefn connect(&mut self) -> Result<(), LsmErrorCode>
fn connect(&mut self) -> Result<(), LsmErrorCode>
Connects to a database on disk.
sourcefn disconnect(&mut self) -> Result<(), LsmErrorCode>
fn disconnect(&mut self) -> Result<(), LsmErrorCode>
Disconnects from a database on disk.
sourcefn persist(&mut self, key: &[u8], value: &[u8]) -> Result<(), LsmErrorCode>
fn persist(&mut self, key: &[u8], value: &[u8]) -> Result<(), LsmErrorCode>
Persists a given value
under the given key
. Observe that both fields
are given as a set of bytes.
sourcefn update(&mut self, key: &[u8], value: &[u8]) -> Result<(), LsmErrorCode>
fn update(&mut self, key: &[u8], value: &[u8]) -> Result<(), LsmErrorCode>
Updates the value stored under key
to the given value
.
sourcefn delete(&mut self, key: &[u8]) -> Result<(), LsmErrorCode>
fn delete(&mut self, key: &[u8]) -> Result<(), LsmErrorCode>
Deletes the value stored under key
.
sourcefn delete_range(&mut self, begin: &[u8], end: &[u8]) -> Result<(), LsmErrorCode>
fn delete_range(&mut self, begin: &[u8], end: &[u8]) -> Result<(), LsmErrorCode>
Deletes all stored values in the open interval (begin, end).
sourcefn optimize(&mut self) -> Result<(), LsmErrorCode>
fn optimize(&mut self) -> Result<(), LsmErrorCode>
Optimizes the database in certain way. This is implementation-defined. For
example, currently lsmlite-rs
optimizes the database for write-once, read-many
workloads (for space and read efficiency). Other underlying implementations
might have different optimization opportunities.
sourcefn begin_transaction(&mut self) -> Result<(), LsmErrorCode>
fn begin_transaction(&mut self) -> Result<(), LsmErrorCode>
Opens a transaction explicitly.
sourcefn commit_transaction(&mut self) -> Result<(), LsmErrorCode>
fn commit_transaction(&mut self) -> Result<(), LsmErrorCode>
Commits the operations contained in the current transaction.
sourcefn rollback_transaction(&mut self) -> Result<(), LsmErrorCode>
fn rollback_transaction(&mut self) -> Result<(), LsmErrorCode>
Rollbacks the operations contained in the current transaction.
sourcefn cursor_open(&self) -> Result<Self::C<'_>, LsmErrorCode>
fn cursor_open(&self) -> Result<Self::C<'_>, LsmErrorCode>
Opens a database cursor.