Struct rusty_leveldb_arc::DB
source · pub struct DB { /* private fields */ }
Expand description
DB contains the actual database implemenation. As opposed to the original, this implementation is not concurrent (yet).
Implementations§
source§impl DB
impl DB
sourcepub fn open<P: AsRef<Path>>(name: P, opt: Options) -> Result<DB>
pub fn open<P: AsRef<Path>>(name: P, opt: Options) -> Result<DB>
Opens or creates a new or existing database. name
is the name of the directory containing
the database.
Whether a new database is created and what happens if a database exists at the given path
depends on the options set (create_if_missing
, error_if_exists
).
source§impl DB
impl DB
sourcepub fn put(&mut self, k: &[u8], v: &[u8]) -> Result<()>
pub fn put(&mut self, k: &[u8], v: &[u8]) -> Result<()>
Adds a single entry. It’s a short, non-synchronous, form of write()
; in order to make
sure that the written entry is on disk, call flush()
afterwards.
sourcepub fn delete(&mut self, k: &[u8]) -> Result<()>
pub fn delete(&mut self, k: &[u8]) -> Result<()>
Deletes a single entry. Like with put()
, you can call flush()
to guarantee that
the operation made it to disk.
source§impl DB
impl DB
source§impl DB
impl DB
sourcepub fn new_iter(&mut self) -> Result<DBIterator>
pub fn new_iter(&mut self) -> Result<DBIterator>
new_iter returns a DBIterator over the current state of the database. The iterator will not return elements added to the database after its creation.
sourcepub fn new_iter_at(&mut self, ss: Snapshot) -> Result<DBIterator>
pub fn new_iter_at(&mut self, ss: Snapshot) -> Result<DBIterator>
new_iter_at returns a DBIterator at the supplied snapshot.
source§impl DB
impl DB
sourcepub fn get_snapshot(&mut self) -> Snapshot
pub fn get_snapshot(&mut self) -> Snapshot
Returns a snapshot at the current state. It can be used to retrieve entries from the database as they were at an earlier point in time.
source§impl DB
impl DB
sourcepub fn compact_range(&mut self, from: &[u8], to: &[u8]) -> Result<()>
pub fn compact_range(&mut self, from: &[u8], to: &[u8]) -> Result<()>
compact_range triggers an immediate compaction on the specified key range. Repeatedly calling this without actually adding new keys is not useful.
Compactions in general will cause the database to find entries more quickly, and take up less space on disk.