1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use leveldb_sys as sys;

/// Leveldb Open options
#[derive(Debug)]
pub struct Options(pub(crate) *mut sys::leveldb_options_t);

impl Options {
    /// Make a new options object
    pub fn new() -> Self {
        let ptr = unsafe { sys::leveldb_options_create() };
        assert!(!ptr.is_null());
        Self(ptr)
    }
}

impl Drop for Options {
    fn drop(&mut self) {
        unsafe { sys::leveldb_options_destroy(self.0) }
    }
}

impl Default for Options {
    fn default() -> Self {
        Self::new()
    }
}

/// Options for reading keys
#[derive(Debug)]
pub struct ReadOptions(pub(crate) *mut sys::leveldb_readoptions_t);

impl ReadOptions {
    /// Make a new ReadOptions object
    pub fn new() -> Self {
        let ptr = unsafe { sys::leveldb_readoptions_create() };
        assert!(!ptr.is_null());
        Self(ptr)
    }
}

impl Drop for ReadOptions {
    fn drop(&mut self) {
        unsafe {
            sys::leveldb_readoptions_destroy(self.0);
        }
    }
}

impl Default for ReadOptions {
    fn default() -> Self {
        ReadOptions::new()
    }
}