Trait lsmlite_rs::Disk

source ·
pub trait Disk
where 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§

source

type C<'a>: Cursor

Required Methods§

source

fn initialize(&mut self, conf: DbConf) -> Result<(), LsmErrorCode>

Initializes a database with a given configuration (of type DbConf).

source

fn connect(&mut self) -> Result<(), LsmErrorCode>

Connects to a database on disk.

source

fn disconnect(&mut self) -> Result<(), LsmErrorCode>

Disconnects from a database on disk.

source

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.

source

fn update(&mut self, key: &[u8], value: &[u8]) -> Result<(), LsmErrorCode>

Updates the value stored under key to the given value.

source

fn delete(&mut self, key: &[u8]) -> Result<(), LsmErrorCode>

Deletes the value stored under key.

source

fn delete_range(&mut self, begin: &[u8], end: &[u8]) -> Result<(), LsmErrorCode>

Deletes all stored values in the open interval (begin, end).

source

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.

source

fn begin_transaction(&mut self) -> Result<(), LsmErrorCode>

Opens a transaction explicitly.

source

fn commit_transaction(&mut self) -> Result<(), LsmErrorCode>

Commits the operations contained in the current transaction.

source

fn rollback_transaction(&mut self) -> Result<(), LsmErrorCode>

Rollbacks the operations contained in the current transaction.

source

fn cursor_open(&self) -> Result<Self::C<'_>, LsmErrorCode>

Opens a database cursor.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Disk for LsmDb

Custom implementation of Disk for LsmDb.

§

type C<'a> = LsmCursor<'a>