fix build for rustc 1.0.0-nightly (ea6f65c5f 2015-01-06 19:47:08 +0000)

without.crypto
Dan Burkert 10 years ago
parent 1b2dbfc6e7
commit 7ffc6df87f
  1. 2
      lmdb-sys/Cargo.toml
  2. 2
      lmdb-sys/mdb
  3. 5
      lmdb-sys/src/lib.rs
  4. 4
      src/database.rs
  5. 5
      src/environment.rs
  6. 9
      src/error.rs
  7. 4
      src/lib.rs

@ -13,7 +13,7 @@ build = "build.rs"
name = "lmdb-sys"
[dependencies.rust-bindgen]
path = "../../rust-bindgen"
git = "https://github.com/crabtw/rust-bindgen.git"
[build-dependencies.pkg-config]
pkg-config = "*"

@ -1 +1 @@
Subproject commit 9cc04f604f80f033d712f5f1faeb4ed97ca74f40
Subproject commit 462dc097451834477b597447af69c5acc93182b7

@ -1,7 +1,8 @@
#![allow(dead_code, uppercase_variables, non_camel_case_types)]
#![feature(phase,globs)]
#![feature(plugin)]
#[phase(plugin)] extern crate bindgen;
#[plugin]
extern crate bindgen;
extern crate libc;
use libc::{size_t, mode_t};

@ -1,5 +1,5 @@
use libc::c_uint;
use std::c_str::ToCStr;
use std::ffi::CString;
use std::ptr;
use ffi;
@ -25,7 +25,7 @@ impl Database {
name: Option<&str>,
flags: c_uint)
-> LmdbResult<Database> {
let c_name = name.map(|n| n.to_c_str());
let c_name = name.map(|n| CString::from_slice(n.as_bytes()));
let name_ptr = if let Some(ref c_name) = c_name { c_name.as_ptr() } else { ptr::null() };
let mut dbi: ffi::MDB_dbi = 0;
try!(lmdb_result(ffi::mdb_dbi_open(txn, name_ptr, flags, &mut dbi)));

@ -1,6 +1,7 @@
use libc::{c_uint, size_t, mode_t};
use std::c_str::ToCStr;
use std::ffi::CString;
use std::io::FilePermission;
use std::path::BytesContainer;
use std::ptr;
use std::sync::Mutex;
@ -177,7 +178,7 @@ impl EnvironmentBuilder {
ffi::mdb_env_close(env))
}
lmdb_try_with_cleanup!(ffi::mdb_env_open(env,
path.to_c_str().as_ptr(),
CString::from_slice(path.container_as_bytes()).as_ptr(),
self.flags.bits(),
mode.bits() as mode_t),
ffi::mdb_env_close(env));

@ -1,4 +1,6 @@
use libc::c_int;
use std;
use std::mem;
use std::error::Error;
use std::str;
@ -106,7 +108,12 @@ impl LmdbError {
impl Error for LmdbError {
fn description(&self) -> &str {
unsafe { str::from_c_str(ffi::mdb_strerror(self.to_err_code()) as *const _) }
unsafe {
// This is safe since the error messages returned from mdb_strerror are static.
let err: &'static *const i8 =
mem::transmute(&(ffi::mdb_strerror(self.to_err_code()) as *const i8));
str::from_utf8_unchecked(std::ffi::c_str_to_bytes(err))
}
}
}

@ -4,9 +4,9 @@
//! 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(phase, globs, macro_rules, unsafe_destructor, associated_types)]
#![feature(phase, unsafe_destructor)]
#[phase(plugin, link)] extern crate log;
#[macro_use] extern crate log;
extern crate libc;
extern crate "lmdb-sys" as ffi;

Loading…
Cancel
Save