Crate rusty_leveldb
source · [−]Expand description
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();
Modules
Macros
Structs
A filter policy using a bloom filter internally.
DB contains the actual database implemenation. As opposed to the original, this implementation
is not concurrent (yet).
DBIterator is an iterator over the contents of a database.
The default byte-wise comparator.
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 contains general parameters for a LevelDB instance. Most of the names are
self-explanatory; the defaults are defined in the
Default
implementation.Status encapsulates a
StatusCode
and an error message. It can be displayed, and also
implements Error
.A WriteBatch contains entries to be written to a MemTable (for example) in a compact form.
Enums
StatusCode describes various failure modes of database operations.
Traits
Comparator trait, supporting types that can be nested (i.e., add additional functionality on
top of an inner comparator)
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.
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
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
LevelDB’s result type