From 530dc462d51b7ac4f54bb1d9a99a8a217700f1e3 Mon Sep 17 00:00:00 2001 From: Martin Ek Date: Mon, 9 Apr 2018 18:59:17 +0200 Subject: [PATCH] Add DBOptions.set_wal_dir --- src/db_options.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/db_options.rs b/src/db_options.rs index 716b6f7..12fe213 100644 --- a/src/db_options.rs +++ b/src/db_options.rs @@ -14,6 +14,7 @@ use std::ffi::{CStr, CString}; use std::mem; +use std::path::Path; use libc::{self, c_int, c_uchar, c_uint, c_void, size_t, uint64_t}; @@ -980,6 +981,26 @@ impl Options { ffi::rocksdb_options_set_num_levels(self.inner, n); } } + + /// Specifies the absolute path of the directory the + /// write-ahead log (WAL) should be written to. + /// + /// Default: same directory as the database + /// + /// # Example + /// + /// ``` + /// use rocksdb::Options; + /// + /// let mut opts = Options::default(); + /// opts.set_wal_dir("/path/to/dir"); + /// ``` + pub fn set_wal_dir>(&mut self, path: P) { + let p = CString::new(path.as_ref().to_string_lossy().as_bytes()).unwrap(); + unsafe { + ffi::rocksdb_options_set_wal_dir(self.inner, p.as_ptr()); + } + } } impl Default for Options {