update README for latest rocksdb version

master
Tyler Neely 9 years ago
parent 4f6b34d8c6
commit a2334ab39a
  1. 5
      README.md
  2. 15
      src/ffi.rs
  3. 11
      src/rocksdb.rs

@ -3,7 +3,7 @@ rust-rocksdb
[![Build Status](https://travis-ci.org/spacejam/rust-rocksdb.svg?branch=master)](https://travis-ci.org/spacejam/rust-rocksdb)
[![crates.io](http://meritbadge.herokuapp.com/rocksdb)](https://crates.io/crates/rocksdb)
This library has been tested against RocksDB 3.8.1 on linux and OSX. The 0.1.1 crate should work with the Rust 1.2 stable and nightly releases as of 9/7/15.
This library has been tested against RocksDB 3.13.1 on linux and OSX. The 0.1.1 crate should work with the Rust 1.2 stable and nightly releases as of 9/7/15.
### status
- [x] basic open/put/get/delete/close
@ -22,6 +22,9 @@ This library has been tested against RocksDB 3.8.1 on linux and OSX. The 0.1.1
Feedback and pull requests welcome! If a particular feature of RocksDB is important to you, please let me know by opening an issue, and I'll prioritize it.
###### Prerequisite: RocksDB
First, use your system's package manager to install snappy. This is optional, but lets rocksdb take advantage of better compression, and some code may require it.
```bash
wget https://github.com/facebook/rocksdb/archive/rocksdb-3.8.tar.gz
tar xvf rocksdb-3.8.tar.gz && cd rocksdb-rocksdb-3.8 && make shared_lib

@ -15,7 +15,8 @@
*/
extern crate libc;
use self::libc::{c_char, c_int, c_void, size_t};
use std::ffi::CString;
use std::ffi::{CString, CStr};
use std::str::from_utf8;
#[derive(Copy, Clone)]
#[repr(C)]
@ -92,6 +93,15 @@ pub enum DBUniversalCompactionStyle {
rocksdb_total_size_compaction_stop_style = 1,
}
pub fn error_message(ptr: *const i8) -> String {
let c_str = unsafe { CStr::from_ptr(ptr) };
let s = from_utf8(c_str.to_bytes()).unwrap().to_owned();
unsafe{
libc::free(ptr as *mut libc::c_void);
}
s
}
//TODO audit the use of boolean arguments, b/c I think they need to be u8 instead...
#[link(name = "rocksdb")]
extern {
@ -410,6 +420,9 @@ fn internal() {
let mut err: *const i8 = 0 as *const i8;
let err_ptr: *mut *const i8 = &mut err;
let db = rocksdb_open(opts, cpath_ptr, err_ptr);
if !err.is_null() {
println!("failed to open rocksdb: {}", error_message(err));
}
assert!(err.is_null());
let writeopts = rocksdb_writeoptions_create();

@ -27,7 +27,7 @@ use std::str::from_utf8;
use self::libc::{c_void, size_t};
use rocksdb_ffi::{self, DBCFHandle};
use rocksdb_ffi::{self, DBCFHandle, error_message};
use rocksdb_options::Options;
pub struct DB {
@ -187,15 +187,6 @@ pub trait Writable {
fn delete_cf(&self, cf: DBCFHandle, key: &[u8]) -> Result<(), String>;
}
fn error_message(ptr: *const i8) -> String {
let c_str = unsafe { CStr::from_ptr(ptr) };
let s = from_utf8(c_str.to_bytes()).unwrap().to_owned();
unsafe{
libc::free(ptr as *mut libc::c_void);
}
s
}
impl DB {
pub fn open_default(path: &str) -> Result<DB, String> {
let mut opts = Options::new();

Loading…
Cancel
Save