From e36d9892e734700bef1dcd198d7082920f6f2b10 Mon Sep 17 00:00:00 2001 From: Ceri Storey Date: Wed, 24 Feb 2016 11:48:13 +0000 Subject: [PATCH] Add DB#write variant with WriteOptions. --- src/rocksdb.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/rocksdb.rs b/src/rocksdb.rs index fd3c47f..5c9b771 100644 --- a/src/rocksdb.rs +++ b/src/rocksdb.rs @@ -366,16 +366,14 @@ impl DB { Ok(()) } - pub fn write(&self, batch: WriteBatch) -> Result<(), String> { - let writeopts = unsafe { rocksdb_ffi::rocksdb_writeoptions_create() }; + pub fn write_opt(&self, batch: WriteBatch, writeopts: &WriteOptions) -> Result<(), String> { let mut err: *const i8 = 0 as *const i8; let err_ptr: *mut *const i8 = &mut err; unsafe { rocksdb_ffi::rocksdb_write(self.inner, - writeopts.clone(), + writeopts.inner, batch.inner, err_ptr); - rocksdb_ffi::rocksdb_writeoptions_destroy(writeopts); } if !err.is_null() { return Err(error_message(err)); @@ -383,6 +381,10 @@ impl DB { return Ok(()); } + pub fn write(&self, batch: WriteBatch) -> Result<(), String> { + self.write_opt(batch, &WriteOptions::new()) + } + pub fn get(&self, key: &[u8]) -> Result, String> { unsafe { let readopts = rocksdb_ffi::rocksdb_readoptions_create();