diff --git a/Cargo.toml b/Cargo.toml index 2ca3e34..1c7449b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,3 +16,6 @@ name = "lmdb" [dependencies.lmdb-sys] path = "lmdb-sys" + +[dependencies.bitflags] +version = "*" diff --git a/lmdb-sys/build.rs b/lmdb-sys/build.rs index 3cc0283..5e07fb3 100644 --- a/lmdb-sys/build.rs +++ b/lmdb-sys/build.rs @@ -1,4 +1,4 @@ -#![allow(unstable)] +#![feature(collections, io, os, path)] extern crate "pkg-config" as pkg_config; extern crate bindgen; @@ -6,7 +6,7 @@ extern crate gcc; use bindgen::{Bindings, BindgenOptions, LinkType}; use std::default::Default; -use std::io::fs; +use std::old_io::fs; use std::os; fn main() { diff --git a/lmdb-sys/src/lib.rs b/lmdb-sys/src/lib.rs index 7ba731a..7b15cea 100644 --- a/lmdb-sys/src/lib.rs +++ b/lmdb-sys/src/lib.rs @@ -4,10 +4,9 @@ non_camel_case_types, non_snake_case, raw_pointer_derive, - unstable, )] -#![feature(plugin)] +#![feature(libc, plugin)] extern crate libc; diff --git a/src/cursor.rs b/src/cursor.rs index 4cf10e8..f6b7f9b 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -296,7 +296,8 @@ impl <'txn> Iterator for IterDup<'txn> { #[cfg(test)] mod test { - use std::{io, ptr}; + use std::old_io as io; + use std::ptr; use test::{Bencher, black_box}; use ffi::*; diff --git a/src/database.rs b/src/database.rs index e54c615..dc61b99 100644 --- a/src/database.rs +++ b/src/database.rs @@ -9,7 +9,7 @@ use error::{LmdbResult, lmdb_result}; /// A handle to an individual database in an environment. /// /// A database handle denotes the name and parameters of a database in an environment. -#[derive(Show, Clone, Copy, Eq, PartialEq)] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] pub struct Database { dbi: ffi::MDB_dbi, } diff --git a/src/environment.rs b/src/environment.rs index 126055a..4ac7cfb 100644 --- a/src/environment.rs +++ b/src/environment.rs @@ -1,6 +1,6 @@ use libc::{c_uint, size_t, mode_t}; use std::ffi::CString; -use std::io::FilePermission; +use std::old_io::FilePermission; use std::path::BytesContainer; use std::ptr; use std::sync::Mutex; @@ -150,7 +150,7 @@ impl Drop for Environment { /////////////////////////////////////////////////////////////////////////////////////////////////// /// Options for opening or creating an environment. -#[derive(Show, PartialEq, Eq, Copy, Clone)] +#[derive(Debug, PartialEq, Eq, Copy, Clone)] pub struct EnvironmentBuilder { flags: EnvironmentFlags, max_readers: Option, @@ -237,7 +237,7 @@ impl EnvironmentBuilder { #[cfg(test)] mod test { - use std::io; + use std::old_io as io; use flags::*; use super::*; @@ -325,7 +325,7 @@ mod test { let env = Environment::new().set_flags(READ_ONLY) .open(dir.path(), io::USER_RWX) .unwrap(); - assert!(env.sync(true).is_ok()); + env.sync(true).unwrap(); } } } diff --git a/src/error.rs b/src/error.rs index 4fb02a5..93f7456 100644 --- a/src/error.rs +++ b/src/error.rs @@ -2,11 +2,12 @@ use libc::c_int; use std; use std::mem; use std::error::Error; +use std::fmt; use std::str; use ffi; -#[derive(Show, Eq, PartialEq, Copy, Clone)] +#[derive(Debug, Eq, PartialEq, Copy, Clone)] pub enum LmdbError { /// key/data pair already exists. KeyExist, @@ -106,6 +107,12 @@ impl LmdbError { } } +impl fmt::Display for LmdbError { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + write!(fmt, "{}", self.description()) + } +} + impl Error for LmdbError { fn description(&self) -> &str { unsafe { diff --git a/src/flags.rs b/src/flags.rs index 04fa8dc..0c17c1f 100644 --- a/src/flags.rs +++ b/src/flags.rs @@ -4,7 +4,7 @@ use ffi::*; bitflags! { #[doc="Environment Options"] - #[derive(Show)] + #[derive(Debug)] flags EnvironmentFlags: c_uint { #[doc="Use a fixed address for the mmap region. This flag must be specified"] @@ -105,7 +105,7 @@ bitflags! { bitflags! { #[doc="Database Options"] - #[derive(Show)] + #[derive(Debug)] flags DatabaseFlags: c_uint { #[doc="Keys are strings to be compared in reverse order, from the end of the strings"] @@ -141,7 +141,7 @@ bitflags! { bitflags! { #[doc="Write Options"] - #[derive(Show)] + #[derive(Debug)] flags WriteFlags: c_uint { #[doc="Insert the new item only if the key does not already appear in the database."] diff --git a/src/lib.rs b/src/lib.rs index f00bece..6f8637d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,15 +4,16 @@ //! Provides the minimal amount of abstraction necessary to interact with LMDB safely in Rust. In //! general, the API is very similar to the LMDB [C-API](http://symas.com/mdb/doc/). -#![feature(unsafe_destructor, optin_builtin_traits)] -#![allow(unstable)] +#![feature(collections, core, hash, io, libc, optin_builtin_traits, path, std_misc, test, unsafe_destructor)] +#![cfg_attr(test, feature(rand))] -#[macro_use] extern crate log; extern crate libc; extern crate "lmdb-sys" as ffi; extern crate test; extern crate collections; +#[macro_use] +extern crate bitflags; pub use cursor::{ Cursor, @@ -63,7 +64,7 @@ mod transaction; #[cfg(test)] mod test_utils { - use std::io; + use std::old_io as io; use super::*; diff --git a/src/transaction.rs b/src/transaction.rs index 8fee272..e4b9cfb 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -1,7 +1,7 @@ use libc::{c_uint, c_void, size_t}; use std::{mem, ptr, raw}; use std::marker; -use std::io::BufWriter; +use std::old_io::BufWriter; use ffi; @@ -365,7 +365,7 @@ impl <'env> Transaction<'env> for RwTransaction<'env> { #[cfg(test)] mod test { - use std::io; + use std::old_io as io; use std::ptr; use std::rand::{Rng, XorShiftRng}; use std::sync::{Arc, Barrier, Future}; @@ -410,7 +410,7 @@ mod test { let mut txn = env.begin_rw_txn().unwrap(); { let mut writer = txn.reserve(db, b"key1", 4, WriteFlags::empty()).unwrap(); - writer.write(b"val1").unwrap(); + writer.write_all(b"val1").unwrap(); } txn.commit().unwrap();