Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skade/leveldb
https://github.com/skade/leveldb
Last synced: 4 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/skade/leveldb
- Owner: skade
- License: mit
- Created: 2014-03-22T18:40:04.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-06-22T11:05:44.000Z (over 2 years ago)
- Last Synced: 2024-04-30T08:32:39.309Z (8 months ago)
- Language: Rust
- Size: 1010 KB
- Stars: 181
- Watchers: 10
- Forks: 50
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rust-cn - skade/leveldb - ci.org/skade/leveldb.svg?branch=master">](https://travis-ci.org/skade/leveldb) (Libraries / Database)
- awesome-rust - skade/leveldb - ci.org/skade/leveldb.svg?branch=master">](https://travis-ci.org/skade/leveldb) (Libraries / Database)
- awesome-rust - skade/leveldb
- awesome-rust-cn - skade/leveldb
- awesome-rust-zh - skade/leveldb - [LevelDB](https://github.com/google/leveldb)绑定 [<img src="https://api.travis-ci.org/skade/leveldb.svg?branch=master">](https://travis-ci.org/skade/leveldb) (库 / 数据库)
- awesome-rust - skade/leveldb - [LevelDB](https://github.com/google/leveldb) bindings (Libraries / Database)
- awesome-rust - skade/leveldb - ci.org/skade/leveldb.svg?branch=master">](https://travis-ci.org/skade/leveldb) (库 Libraries / 数据库 Database)
- fucking-awesome-rust - skade/leveldb - <b><code> 36724⭐</code></b> <b><code> 7855🍴</code></b> [LevelDB](https://github.com/google/leveldb)) bindings (Libraries / Database)
- fucking-awesome-rust - skade/leveldb - <b><code> 36216⭐</code></b> <b><code> 7791🍴</code></b> [LevelDB](https://github.com/google/leveldb)) bindings (Libraries / Database)
README
# Rust leveldb bindings
Almost-complete bindings for leveldb for Rust.
[Documentation](https://docs.rs/leveldb/0.8.4/leveldb/)
## Rust version policy
`leveldb` is built and tested on stable releases of Rust. This are currently `1.31.0` and `1.43.1`. Nightlies
might not build at any point and failures are allowed. There are no known issues with nightlies, though.## Prerequisites
`snappy` and `leveldb` need to be installed. On Ubuntu, I recommend:
```sh
sudo apt-get install libleveldb-dev libsnappy-dev
```## Usage
If your project is using [Cargo](http://crates.io), drop the following lines in your `Cargo.toml`:
```text
[dependencies]leveldb = "0.8"
```## Development
Make sure you have all prerequisites installed. Run
```sh
$ cargo build
```for building and
```sh
$ cargo test
```to run the test suite.
## Examples
```rust
extern crate tempdir;
extern crate leveldb;use tempdir::TempDir;
use leveldb::database::Database;
use leveldb::iterator::Iterable;
use leveldb::kv::KV;
use leveldb::options::{Options,WriteOptions,ReadOptions};fn main() {
let tempdir = TempDir::new("demo").unwrap();
let path = tempdir.path();let mut options = Options::new();
options.create_if_missing = true;
let mut database = match Database::open(path, options) {
Ok(db) => { db },
Err(e) => { panic!("failed to open database: {:?}", e) }
};let write_opts = WriteOptions::new();
match database.put(write_opts, 1, &[1]) {
Ok(_) => { () },
Err(e) => { panic!("failed to write to database: {:?}", e) }
};let read_opts = ReadOptions::new();
let res = database.get(read_opts, 1);match res {
Ok(data) => {
assert!(data.is_some());
assert_eq!(data, Some(vec![1]));
}
Err(e) => { panic!("failed reading data: {:?}", e) }
}let read_opts = ReadOptions::new();
let mut iter = database.iter(read_opts);
let entry = iter.next();
assert_eq!(
entry,
Some((1, vec![1]))
);
}
```## Open issues
* Filter policies are missing
* Iterators with arbirary start and end points are unsupported# License
MIT, see `LICENSE`