Struct rusty_leveldb::DB
[−]
[src]
pub struct DB { /* fields omitted */ }
DB contains the actual database implemenation. As opposed to the original, this implementation is not concurrent (yet).
Methods
impl DB
[src]
fn open(name: &str, opt: Options) -> Result<DB>
[src]
Opens or creates* a new or existing database.
*depending on the options set (create_if_missing, error_if_exists).
impl DB
[src]
fn put(&mut self, k: &[u8], v: &[u8]) -> Result<()>
[src]
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.
fn delete(&mut self, k: &[u8]) -> Result<()>
[src]
Deletes a single entry. Like with put()
, you can call flush()
to guarantee that
the operation made it to disk.
fn write(&mut self, batch: WriteBatch, sync: bool) -> Result<()>
[src]
Writes an entire WriteBatch. sync
determines whether the write should be flushed to
disk.
fn flush(&mut self) -> Result<()>
[src]
flush makes sure that all pending changes (e.g. from put()) are stored on disk.
impl DB
[src]
fn get_at(&mut self, snapshot: &Snapshot, key: &[u8]) -> Result<Option<Vec<u8>>>
[src]
get_at reads the value for a given key at or before snapshot. It returns Ok(None) if the entry wasn't found, and Err(_) if an error occurred.
fn get(&mut self, key: &[u8]) -> Option<Vec<u8>>
[src]
get is a simplified version of get_at(), translating errors to None.
impl DB
[src]
fn new_iter(&mut self) -> Result<DBIterator>
[src]
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.
fn new_iter_at(&mut self, ss: Snapshot) -> Result<DBIterator>
[src]
new_iter_at returns a DBIterator at the supplied snapshot.
impl DB
[src]
fn get_snapshot(&mut self) -> Snapshot
[src]
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.
impl DB
[src]
fn compact_range(&mut self, from: &[u8], to: &[u8]) -> Result<()>
[src]
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.