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
//! 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 = "exonum_leveldb"] #![deny(missing_docs)] extern crate libc; extern crate leveldb_sys; use leveldb_sys::{leveldb_major_version, leveldb_minor_version}; pub use database::options; pub use database::error; pub use database::iterator; pub use database::snapshots; pub use database::comparator; pub use database::kv; pub use database::batch; pub use database::management; pub use database::compaction; #[allow(missing_docs)] pub mod database; /// 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 } } }