Disk

Trait 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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Disk for LsmDb

Custom implementation of Disk for LsmDb.

Source§

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