Crate rusty_leveldb [] [src]

rusty-leveldb is a reimplementation of LevelDB in pure rust. It depends only on a few crates, and is very close to the original, implementation-wise. The external API is relatively small and should be easy to use.

use rusty_leveldb::{DB, DBIterator, LdbIterator, Options};

let opt = rusty_leveldb::in_memory();
let mut db = DB::open("mydatabase", opt).unwrap();

db.put(b"Hello", b"World").unwrap();
assert_eq!(b"World", db.get(b"Hello").unwrap().as_slice());

let mut iter = db.new_iter().unwrap();
// Note: For efficiency reasons, it's recommended to use advance() and current() instead of
// next() when iterating over many elements.
assert_eq!((b"Hello".to_vec(), b"World".to_vec()), iter.next().unwrap());

db.delete(b"Hello").unwrap();
db.flush().unwrap();

Macros

log

Structs

BloomPolicy

A filter policy using a bloom filter internally.

DB

DB contains the actual database implemenation. As opposed to the original, this implementation is not concurrent (yet).

DBIterator

DBIterator is an iterator over the contents of a database.

DefaultCmp

The default byte-wise comparator.

MemEnv

MemEnv is an in-memory environment that can be used for testing or ephemeral databases. The performance will be better than what a disk environment delivers.

Options

Options contains general parameters for a LevelDB instance. Most of the names are self-explanatory; the defaults are defined in the Default implementation.

PosixDiskEnv
Status

Status encapsulates a StatusCode and an error message. It can be displayed, and also implements Error.

WriteBatch

A WriteBatch contains entries to be written to a MemTable (for example) in a compact form.

Enums

CompressionType
StatusCode

StatusCode describes various failure modes of database operations.

Traits

Cmp

Comparator trait, supporting types that can be nested (i.e., add additional functionality on top of an inner comparator)

Env
FilterPolicy

Encapsulates a filter algorithm allowing to search for keys more efficiently. Usually, policies are used as a BoxedFilterPolicy (see below), so they can be easily cloned and nested.

LdbIterator

An extension of the standard Iterator trait that supports some methods necessary for LevelDB. This works because the iterators used are stateful and keep the last returned element.

Functions

in_memory

Returns Options that will cause a database to exist purely in-memory instead of being stored on disk. This is useful for testing or ephemeral databases.

Type Definitions

Result

LevelDB's result type