ckb_rocksdb/
column_family.rs

1// Copyright 2019 Tyler Neely
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use crate::{handle::Handle, ColumnFamily, Options};
16
17/// A descriptor for a RocksDB column family.
18///
19/// A description of the column family, containing the name and `Options`.
20#[derive(Clone)]
21pub struct ColumnFamilyDescriptor {
22    pub name: String,
23    pub options: Options,
24}
25
26impl ColumnFamilyDescriptor {
27    /// Create a new column family descriptor with the specified name and options.
28    pub fn new<S>(name: S, options: Options) -> Self
29    where
30        S: Into<String>,
31    {
32        ColumnFamilyDescriptor {
33            name: name.into(),
34            options,
35        }
36    }
37
38    pub fn name(&self) -> &str {
39        &self.name
40    }
41}
42
43impl ColumnFamily {
44    pub(crate) fn new(handle: *mut ffi::rocksdb_column_family_handle_t) -> ColumnFamily {
45        ColumnFamily { inner: handle }
46    }
47}
48
49impl Handle<ffi::rocksdb_column_family_handle_t> for ColumnFamily {
50    fn handle(&self) -> *mut ffi::rocksdb_column_family_handle_t {
51        self.inner
52    }
53}