forked from skade/leveldb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.rs
79 lines (72 loc) · 1.94 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! A database access library for leveldb
//!
//! Usage:
//!
//! ```rust,ignore
//! extern crate tempdir;
//! extern crate leveldb;
//!
//! use tempdir::TempDir;
//! use leveldb::database::Database;
//! use leveldb::kv::KV;
//! use leveldb::options::{Options,WriteOptions,ReadOptions};
//!
//! 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) }
//! }
//! ```
#![crate_type = "lib"]
#![crate_name = "leveldb"]
#![deny(missing_docs)]
extern crate libc;
#[macro_use]
extern crate ffi_opaque;
pub use crate::database::batch;
pub use crate::database::compaction;
pub use crate::database::comparator;
pub use crate::database::error;
pub use crate::database::iterator;
pub use crate::database::kv;
pub use crate::database::management;
pub use crate::database::options;
pub use crate::database::snapshots;
pub use crate::leveldb::{leveldb_major_version, leveldb_minor_version};
#[allow(missing_docs)]
pub mod database;
pub mod leveldb;
/// Library version information
///
/// Need a recent version of leveldb to be used.
pub trait Version {
/// The major version.
fn major() -> isize {
unsafe { leveldb_major_version() as isize }
}
/// The minor version
fn minor() -> isize {
unsafe { leveldb_minor_version() as isize }
}
}