makes mdb_version available to FFI

without.crypto
Niko 2 years ago
parent 0935a25673
commit 215d8d0b81
  1. 52
      src/environment.rs

@ -1,44 +1,24 @@
use libc::{
c_uint,
size_t,
};
use libc::{c_uint, size_t};
use std::ffi::CStr;
use std::ffi::CString;
#[cfg(windows)]
use std::ffi::OsStr;
use std::os::raw::c_char;
#[cfg(unix)]
use std::os::unix::ffi::OsStrExt;
use std::path::Path;
use std::sync::Mutex;
use std::{
fmt,
mem,
ptr,
result,
};
use std::{fmt, mem, ptr, result};
use ffi;
use byteorder::{
ByteOrder,
NativeEndian,
};
use byteorder::{ByteOrder, NativeEndian};
use cursor::Cursor;
use database::Database;
use error::{
lmdb_result,
Error,
Result,
};
use flags::{
DatabaseFlags,
EnvironmentFlags,
};
use transaction::{
RoTransaction,
RwTransaction,
Transaction,
};
use error::{lmdb_result, Error, Result};
use flags::{DatabaseFlags, EnvironmentFlags};
use transaction::{RoTransaction, RwTransaction, Transaction};
#[cfg(windows)]
/// Adding a 'missing' trait from windows OsStrExt
@ -202,6 +182,17 @@ impl Environment {
}
}
/// Retrieves version string about this environment.
pub fn version(&self) -> &str {
unsafe {
let mut major: i32 = 0;
let mut minor: i32 = 0;
let mut patch: i32 = 0;
let version: *const c_char = ffi::mdb_version(&mut major, &mut minor, &mut patch) as *const c_char;
std::str::from_utf8_unchecked(CStr::from_ptr(version).to_bytes())
}
}
/// Retrieves the total number of pages on the freelist.
///
/// Along with `Environment::info()`, this can be used to calculate the exact number
@ -487,10 +478,7 @@ mod test {
extern crate byteorder;
use self::byteorder::{
ByteOrder,
LittleEndian,
};
use self::byteorder::{ByteOrder, LittleEndian};
use tempdir::TempDir;
use flags::*;

Loading…
Cancel
Save