Move to Rust 2018 (#375)

master
wqfish 5 years ago committed by Oleksandr Anyshchenko
parent 04e75d6ae5
commit 4f9524bd36
  1. 1
      Cargo.toml
  2. 1
      librocksdb-sys/Cargo.toml
  3. 4
      librocksdb-sys/build.rs
  4. 6
      librocksdb-sys/src/lib.rs
  5. 13
      librocksdb-sys/tests/ffi.rs
  6. 3
      src/backup.rs
  7. 10
      src/checkpoint.rs
  8. 2
      src/compaction_filter.rs
  9. 7
      src/db.rs
  10. 17
      src/db_options.rs
  11. 14
      src/lib.rs
  12. 4
      src/merge_operator.rs
  13. 2
      src/slice_transform.rs
  14. 2
      tests/test_backup.rs
  15. 5
      tests/test_checkpoint.rs
  16. 5
      tests/test_column_family.rs
  17. 6
      tests/test_compationfilter.rs
  18. 5
      tests/test_db.rs
  19. 5
      tests/test_iterator.rs
  20. 5
      tests/test_multithreaded.rs
  21. 3
      tests/test_pinnable_slice.rs
  22. 5
      tests/test_property.rs
  23. 5
      tests/test_raw_iterator.rs
  24. 5
      tests/test_rocksdb_options.rs
  25. 3
      tests/test_slice_transform.rs
  26. 2
      tests/test_write_batch.rs
  27. 2
      tests/util/mod.rs

@ -2,6 +2,7 @@
name = "rocksdb" name = "rocksdb"
description = "Rust wrapper for Facebook's RocksDB embeddable database" description = "Rust wrapper for Facebook's RocksDB embeddable database"
version = "0.13.0" version = "0.13.0"
edition = "2018"
authors = ["Tyler Neely <t@jujit.su>", "David Greenberg <dsg123456789@gmail.com>"] authors = ["Tyler Neely <t@jujit.su>", "David Greenberg <dsg123456789@gmail.com>"]
license = "Apache-2.0" license = "Apache-2.0"
keywords = ["database", "embedded", "LSM-tree", "persistence"] keywords = ["database", "embedded", "LSM-tree", "persistence"]

@ -1,6 +1,7 @@
[package] [package]
name = "librocksdb-sys" name = "librocksdb-sys"
version = "6.4.6" version = "6.4.6"
edition = "2018"
authors = ["Karl Hobley <karlhobley10@gmail.com>", "Arkadiy Paronyan <arkadiy@ethcore.io>"] authors = ["Karl Hobley <karlhobley10@gmail.com>", "Arkadiy Paronyan <arkadiy@ethcore.io>"]
license = "MIT/Apache-2.0/BSD-3-Clause" license = "MIT/Apache-2.0/BSD-3-Clause"
description = "Native bindings to librocksdb" description = "Native bindings to librocksdb"

@ -1,7 +1,3 @@
extern crate bindgen;
extern crate cc;
extern crate glob;
use std::env; use std::env;
use std::fs; use std::fs;
use std::path::PathBuf; use std::path::PathBuf;

@ -16,14 +16,10 @@
#![allow(non_snake_case)] #![allow(non_snake_case)]
#![allow(non_upper_case_globals)] #![allow(non_upper_case_globals)]
extern crate libc;
use libc::c_int;
include!(concat!(env!("OUT_DIR"), "/bindings.rs")); include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
#[cfg(feature = "bzip2")] #[cfg(feature = "bzip2")]
#[no_mangle] #[no_mangle]
pub fn bz_internal_error(errcode: c_int) { pub fn bz_internal_error(errcode: libc::c_int) {
panic!("bz internal error: {}", errcode); panic!("bz internal error: {}", errcode);
} }

@ -23,14 +23,9 @@
unused_variables unused_variables
)] )]
#[macro_use] use const_cstr::const_cstr;
extern crate const_cstr;
extern crate libc;
extern crate librocksdb_sys as ffi;
extern crate uuid;
use ffi::*;
use libc::*; use libc::*;
use librocksdb_sys::*;
use std::borrow::Cow; use std::borrow::Cow;
use std::env; use std::env;
use std::ffi::{CStr, CString}; use std::ffi::{CStr, CString};
@ -46,10 +41,6 @@ macro_rules! err_println {
($($arg:tt)*) => (writeln!(&mut ::std::io::stderr(), $($arg)*).expect("failed printing to stderr")); ($($arg:tt)*) => (writeln!(&mut ::std::io::stderr(), $($arg)*).expect("failed printing to stderr"));
} }
macro_rules! cstr {
($($arg:tt)*) => (const_cstr!($($arg)*));
}
macro_rules! cstrp { macro_rules! cstrp {
($($arg:tt)*) => (const_cstr!($($arg)*).as_ptr()); ($($arg:tt)*) => (const_cstr!($($arg)*).as_ptr());
} }

@ -13,8 +13,7 @@
// limitations under the License. // limitations under the License.
// //
use ffi; use crate::{ffi, Error, DB};
use {Error, DB};
use libc::c_int; use libc::c_int;
use std::ffi::CString; use std::ffi::CString;

@ -13,13 +13,13 @@
// limitations under the License. // limitations under the License.
// //
use ffi; //! Implementation of bindings to RocksDB Checkpoint[1] API
//!
//! [1]: https://github.com/facebook/rocksdb/wiki/Checkpoints
use crate::{ffi, Error, DB};
use std::ffi::CString; use std::ffi::CString;
use std::path::Path; use std::path::Path;
///! Implementation of bindings to RocksDB Checkpoint[1] API
///
/// [1]: https://github.com/facebook/rocksdb/wiki/Checkpoints
use {Error, DB};
/// Undocumented parameter for `ffi::rocksdb_checkpoint_create` function. Zero by default. /// Undocumented parameter for `ffi::rocksdb_checkpoint_create` function. Zero by default.
const LOG_SIZE_FOR_FLUSH: u64 = 0_u64; const LOG_SIZE_FOR_FLUSH: u64 = 0_u64;

@ -116,7 +116,7 @@ fn test_filter(level: u32, key: &[u8], value: &[u8]) -> Decision {
#[test] #[test]
fn compaction_filter_test() { fn compaction_filter_test() {
use {Options, DB}; use crate::{Options, DB};
let path = "_rust_rocksdb_filtertest"; let path = "_rust_rocksdb_filtertest";
let mut opts = Options::default(); let mut opts = Options::default();

@ -13,9 +13,10 @@
// limitations under the License. // limitations under the License.
// //
use ffi; use crate::{
use ffi_util::opt_bytes_to_ptr; ffi, ffi_util::opt_bytes_to_ptr, ColumnFamily, ColumnFamilyDescriptor, Error, FlushOptions,
use {ColumnFamily, ColumnFamilyDescriptor, Error, FlushOptions, Options, WriteOptions, DB}; Options, WriteOptions, DB,
};
use libc::{self, c_char, c_int, c_uchar, c_void, size_t}; use libc::{self, c_char, c_int, c_uchar, c_void, size_t};
use std::collections::BTreeMap; use std::collections::BTreeMap;

@ -18,14 +18,14 @@ use std::path::Path;
use libc::{self, c_int, c_uchar, c_uint, c_void, size_t}; use libc::{self, c_int, c_uchar, c_uint, c_void, size_t};
use compaction_filter::{self, filter_callback, CompactionFilterCallback, CompactionFilterFn}; use crate::{
use comparator::{self, ComparatorCallback, CompareFn}; compaction_filter::{self, filter_callback, CompactionFilterCallback, CompactionFilterFn},
use ffi; comparator::{self, ComparatorCallback, CompareFn},
use merge_operator::{ ffi,
merge_operator::{
self, full_merge_callback, partial_merge_callback, MergeFn, MergeOperatorCallback, self, full_merge_callback, partial_merge_callback, MergeFn, MergeOperatorCallback,
}; },
use slice_transform::SliceTransform; slice_transform::SliceTransform,
use {
BlockBasedIndexType, BlockBasedOptions, DBCompactionStyle, DBCompressionType, DBRecoveryMode, BlockBasedIndexType, BlockBasedOptions, DBCompactionStyle, DBCompressionType, DBRecoveryMode,
FlushOptions, MemtableFactory, Options, PlainTableFactoryOptions, WriteOptions, FlushOptions, MemtableFactory, Options, PlainTableFactoryOptions, WriteOptions,
}; };
@ -1474,8 +1474,7 @@ impl Default for WriteOptions {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use MemtableFactory; use crate::{MemtableFactory, Options};
use Options;
#[test] #[test]
fn test_enable_statistics() { fn test_enable_statistics() {

@ -54,9 +54,6 @@
//! ``` //! ```
//! //!
extern crate libc;
extern crate librocksdb_sys as ffi;
#[macro_use] #[macro_use]
mod ffi_util; mod ffi_util;
@ -69,16 +66,19 @@ mod db_options;
pub mod merge_operator; pub mod merge_operator;
mod slice_transform; mod slice_transform;
pub use compaction_filter::Decision as CompactionDecision; pub use crate::{
pub use db::{ compaction_filter::Decision as CompactionDecision,
db::{
DBCompactionStyle, DBCompressionType, DBIterator, DBPinnableSlice, DBRawIterator, DBCompactionStyle, DBCompressionType, DBIterator, DBPinnableSlice, DBRawIterator,
DBRecoveryMode, DBWALIterator, Direction, IteratorMode, ReadOptions, Snapshot, WriteBatch, DBRecoveryMode, DBWALIterator, Direction, IteratorMode, ReadOptions, Snapshot, WriteBatch,
WriteBatchIterator, WriteBatchIterator,
},
merge_operator::MergeOperands,
slice_transform::SliceTransform,
}; };
pub use slice_transform::SliceTransform; use librocksdb_sys as ffi;
pub use merge_operator::MergeOperands;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::error; use std::error;
use std::fmt; use std::fmt;

@ -225,7 +225,7 @@ mod test {
#[test] #[test]
fn mergetest() { fn mergetest() {
use {Options, DB}; use crate::{Options, DB};
let path = "_rust_rocksdb_mergetest"; let path = "_rust_rocksdb_mergetest";
let mut opts = Options::default(); let mut opts = Options::default();
@ -329,9 +329,9 @@ mod test {
#[test] #[test]
fn counting_mergetest() { fn counting_mergetest() {
use crate::{DBCompactionStyle, Options, DB};
use std::sync::Arc; use std::sync::Arc;
use std::thread; use std::thread;
use {DBCompactionStyle, Options, DB};
let path = "_rust_rocksdb_partial_mergetest"; let path = "_rust_rocksdb_partial_mergetest";
let mut opts = Options::default(); let mut opts = Options::default();

@ -17,7 +17,7 @@ use std::slice;
use libc::{c_char, c_void, size_t}; use libc::{c_char, c_void, size_t};
use ffi; use crate::ffi;
/// A SliceTranform is a generic pluggable way of transforming one string /// A SliceTranform is a generic pluggable way of transforming one string
/// to another. Its primary use-case is in configuring rocksdb /// to another. Its primary use-case is in configuring rocksdb

@ -11,8 +11,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//
extern crate rocksdb;
use rocksdb::{ use rocksdb::{
backup::{BackupEngine, BackupEngineOptions, RestoreOptions}, backup::{BackupEngine, BackupEngineOptions, RestoreOptions},

@ -11,12 +11,11 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//
extern crate rocksdb;
mod util; mod util;
use crate::util::DBPath;
use rocksdb::{checkpoint::Checkpoint, Options, DB}; use rocksdb::{checkpoint::Checkpoint, Options, DB};
use util::DBPath;
#[test] #[test]
pub fn test_single_checkpoint() { pub fn test_single_checkpoint() {

@ -11,12 +11,11 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//
extern crate rocksdb;
mod util; mod util;
use crate::util::DBPath;
use rocksdb::{ColumnFamilyDescriptor, MergeOperands, Options, DB}; use rocksdb::{ColumnFamilyDescriptor, MergeOperands, Options, DB};
use util::DBPath;
#[test] #[test]
fn test_column_family() { fn test_column_family() {

@ -12,12 +12,10 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
extern crate rocksdb;
mod util; mod util;
use crate::util::DBPath;
use rocksdb::{CompactionDecision, Options, DB}; use rocksdb::{CompactionDecision, Options, DB};
use util::DBPath;
#[cfg(test)] #[cfg(test)]
#[allow(unused_variables)] #[allow(unused_variables)]
@ -32,8 +30,6 @@ fn test_filter(level: u32, key: &[u8], value: &[u8]) -> CompactionDecision {
#[test] #[test]
fn compaction_filter_test() { fn compaction_filter_test() {
use {Options, DB};
let path = DBPath::new("_rust_rocksdb_filtertest"); let path = DBPath::new("_rust_rocksdb_filtertest");
let mut opts = Options::default(); let mut opts = Options::default();
opts.create_if_missing(true); opts.create_if_missing(true);

@ -12,15 +12,12 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
extern crate libc;
extern crate rocksdb;
mod util; mod util;
use crate::util::DBPath;
use rocksdb::{Error, IteratorMode, Options, Snapshot, WriteBatch, DB}; use rocksdb::{Error, IteratorMode, Options, Snapshot, WriteBatch, DB};
use std::sync::Arc; use std::sync::Arc;
use std::{mem, thread}; use std::{mem, thread};
use util::DBPath;
#[test] #[test]
fn external() { fn external() {

@ -11,12 +11,11 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//
extern crate rocksdb;
mod util; mod util;
use crate::util::DBPath;
use rocksdb::{Direction, IteratorMode, MemtableFactory, Options, DB}; use rocksdb::{Direction, IteratorMode, MemtableFactory, Options, DB};
use util::DBPath;
fn cba(input: &[u8]) -> Box<[u8]> { fn cba(input: &[u8]) -> Box<[u8]> {
input.to_vec().into_boxed_slice() input.to_vec().into_boxed_slice()

@ -11,14 +11,13 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//
extern crate rocksdb;
mod util; mod util;
use crate::util::DBPath;
use rocksdb::DB; use rocksdb::DB;
use std::sync::Arc; use std::sync::Arc;
use std::thread; use std::thread;
use util::DBPath;
const N: usize = 100_000; const N: usize = 100_000;

@ -1,8 +1,7 @@
extern crate rocksdb;
mod util; mod util;
use crate::util::DBPath;
use rocksdb::{Options, DB}; use rocksdb::{Options, DB};
use util::DBPath;
#[test] #[test]
fn test_pinnable_slice() { fn test_pinnable_slice() {

@ -11,12 +11,11 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//
extern crate rocksdb;
mod util; mod util;
use crate::util::DBPath;
use rocksdb::{Options, DB}; use rocksdb::{Options, DB};
use util::DBPath;
#[test] #[test]
fn property_test() { fn property_test() {

@ -11,12 +11,11 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//
extern crate rocksdb;
mod util; mod util;
use crate::util::DBPath;
use rocksdb::DB; use rocksdb::DB;
use util::DBPath;
#[test] #[test]
pub fn test_forwards_iteration() { pub fn test_forwards_iteration() {

@ -11,13 +11,12 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//
extern crate rocksdb;
mod util; mod util;
use crate::util::DBPath;
use rocksdb::{BlockBasedOptions, Options, ReadOptions, DB}; use rocksdb::{BlockBasedOptions, Options, ReadOptions, DB};
use std::{fs, io::Read as _}; use std::{fs, io::Read as _};
use util::DBPath;
#[test] #[test]
fn test_set_num_levels() { fn test_set_num_levels() {

@ -1,8 +1,7 @@
extern crate rocksdb;
mod util; mod util;
use crate::util::DBPath;
use rocksdb::{Options, SliceTransform, DB}; use rocksdb::{Options, SliceTransform, DB};
use util::DBPath;
#[test] #[test]
pub fn test_slice_transform() { pub fn test_slice_transform() {

@ -11,8 +11,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//
extern crate rocksdb;
use rocksdb::WriteBatch; use rocksdb::WriteBatch;

@ -1,5 +1,3 @@
extern crate rocksdb;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::time::{SystemTime, UNIX_EPOCH}; use std::time::{SystemTime, UNIX_EPOCH};

Loading…
Cancel
Save