Struct typed_store::rocks::DBMap
source · [−]pub struct DBMap<K, V> {
pub rocksdb: Arc<DBWithThreadMode<MultiThreaded>>,
/* private fields */
}
Expand description
An interface to a rocksDB database, keyed by a columnfamily
Fields
rocksdb: Arc<DBWithThreadMode<MultiThreaded>>
Implementations
sourceimpl<K, V> DBMap<K, V>
impl<K, V> DBMap<K, V>
sourcepub fn open<P: AsRef<Path>>(
path: P,
db_options: Option<Options>,
opt_cf: Option<&str>
) -> Result<Self, TypedStoreError>
pub fn open<P: AsRef<Path>>(
path: P,
db_options: Option<Options>,
opt_cf: Option<&str>
) -> Result<Self, TypedStoreError>
Opens a database from a path, with specific options and an optional column family.
This database is used to perform operations on single column family, and parametrizes
all operations in DBBatch
when writting across column families.
sourcepub fn reopen(
db: &Arc<DBWithThreadMode<MultiThreaded>>,
opt_cf: Option<&str>
) -> Result<Self, TypedStoreError>
pub fn reopen(
db: &Arc<DBWithThreadMode<MultiThreaded>>,
opt_cf: Option<&str>
) -> Result<Self, TypedStoreError>
Reopens an open database as a typed map operating under a specific column family. if no column family is passed, the default column family is used.
use typed_store::rocks::*;
use tempfile::tempdir;
/// Open the DB with all needed column families first.
let rocks = open_cf(tempdir().unwrap(), None, &["First_CF", "Second_CF"]).unwrap();
/// Attach the column families to specific maps.
let db_cf_1 = DBMap::<u32,u32>::reopen(&rocks, Some("First_CF")).expect("Failed to open storage");
let db_cf_2 = DBMap::<u32,u32>::reopen(&rocks, Some("Second_CF")).expect("Failed to open storage");
pub fn batch(&self) -> DBBatch
Trait Implementations
sourceimpl<'a, K, V> Map<'a, K, V> for DBMap<K, V> where
K: Serialize + DeserializeOwned,
V: Serialize + DeserializeOwned,
impl<'a, K, V> Map<'a, K, V> for DBMap<K, V> where
K: Serialize + DeserializeOwned,
V: Serialize + DeserializeOwned,
sourcefn multi_get<J>(
&self,
keys: impl IntoIterator<Item = J>
) -> Result<Vec<Option<V>>, TypedStoreError> where
J: Borrow<K>,
fn multi_get<J>(
&self,
keys: impl IntoIterator<Item = J>
) -> Result<Vec<Option<V>>, TypedStoreError> where
J: Borrow<K>,
Returns a vector of values corresponding to the keys provided.
type Error = TypedStoreError
type Iterator = Iter<'a, K, V>
type Keys = Keys<'a, K>
type Values = Values<'a, V>
sourcefn contains_key(&self, key: &K) -> Result<bool, TypedStoreError>
fn contains_key(&self, key: &K) -> Result<bool, TypedStoreError>
Returns true if the map contains a value for the specified key.
sourcefn get(&self, key: &K) -> Result<Option<V>, TypedStoreError>
fn get(&self, key: &K) -> Result<Option<V>, TypedStoreError>
Returns the value for the given key from the map, if it exists.
sourcefn insert(&self, key: &K, value: &V) -> Result<(), TypedStoreError>
fn insert(&self, key: &K, value: &V) -> Result<(), TypedStoreError>
Inserts the given key-value pair into the map.
sourcefn remove(&self, key: &K) -> Result<(), TypedStoreError>
fn remove(&self, key: &K) -> Result<(), TypedStoreError>
Removes the entry for the given key from the map.
sourcefn clear(&self) -> Result<(), TypedStoreError>
fn clear(&self) -> Result<(), TypedStoreError>
Removes every key-value pair from the map.
sourcefn iter(&'a self) -> Self::Iterator
fn iter(&'a self) -> Self::Iterator
Returns an iterator visiting each key-value pair in the map.
sourcefn multi_insert<J, U>(
&self,
key_val_pairs: impl IntoIterator<Item = (J, U)>
) -> Result<(), Self::Error> where
J: Borrow<K>,
U: Borrow<V>,
fn multi_insert<J, U>(
&self,
key_val_pairs: impl IntoIterator<Item = (J, U)>
) -> Result<(), Self::Error> where
J: Borrow<K>,
U: Borrow<V>,
Inserts key-value pairs.
sourcefn multi_remove<J>(
&self,
keys: impl IntoIterator<Item = J>
) -> Result<(), Self::Error> where
J: Borrow<K>,
fn multi_remove<J>(
&self,
keys: impl IntoIterator<Item = J>
) -> Result<(), Self::Error> where
J: Borrow<K>,
Removes keys.
sourceimpl<'a, J, K, U, V> TryExtend<(J, U)> for DBMap<K, V> where
J: Borrow<K>,
U: Borrow<V>,
K: Serialize,
V: Serialize,
impl<'a, J, K, U, V> TryExtend<(J, U)> for DBMap<K, V> where
J: Borrow<K>,
U: Borrow<V>,
K: Serialize,
V: Serialize,
type Error = TypedStoreError
type Error = TypedStoreError
Error type.
impl<K: Send, V: Send> Send for DBMap<K, V>
Auto Trait Implementations
impl<K, V> RefUnwindSafe for DBMap<K, V>
impl<K, V> Sync for DBMap<K, V>
impl<K, V> Unpin for DBMap<K, V>
impl<K, V> UnwindSafe for DBMap<K, V>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more