[][src]Struct icbiadb::database::kv::KvDb

pub struct KvDb<KV: KvInterface> {
    pub file_name: String,
    pub records: KV,
}

Fields

file_name: Stringrecords: KV

Implementations

impl<KV> KvDb<KV> where
    KV: KvInterface<Key = BvString, Value = BvObject, RefKey = [u8]>,
    &'a KV: IntoIterator<Item = (&'a BvString, &'a BvObject)>, 
[src]

pub fn commit(&self) -> Result<()>[src]

Write the in-memory database to file

pub fn len(&self) -> usize[src]

Return the number of records stored in the database

pub fn has_key<S: AsRef<str>>(&self, key: S) -> bool[src]

Check if the key already exists

pub fn incr<S: AsRef<str>>(&mut self, key: S)[src]

Increment key by 1, isize is used by default if the key don't exists

pub fn incr_by<S, T>(&mut self, key: S, val: T) where
    S: AsRef<str>,
    T: Serialize + DeserializeOwned + Add,
    <T as Add>::Output: Serialize
[src]

Increment key by T, isize is used by default if the key don't exists

pub fn decr<S: AsRef<str>>(&mut self, key: S)[src]

Decrement key by 1, isize is used by default if the key don't exists

pub fn decr_by<S, T>(&mut self, key: S, val: T) where
    S: AsRef<str>,
    T: Serialize + DeserializeOwned + Sub,
    <T as Sub>::Output: Serialize
[src]

Decrement key by T, isize is used by default if the key don't exists

pub fn swap<S: AsRef<str>, T: Serialize>(
    &mut self,
    key: S,
    value: T
) -> BvObject
[src]

Replace value with mem::replace and return the old value

pub fn set<S: AsRef<str>, T: Sized + Serialize>(&mut self, key: S, value: T)[src]

Set a key to value T

pub fn set_as<S: AsRef<str>, T: Sized + Serialize>(
    &mut self,
    key: S,
    t: S,
    value: T
)
[src]

Set a key to value T with type name S

pub fn set_raw<S: AsRef<str>>(&mut self, key: S, type_name: S, value: Vec<u8>)[src]

Set a key to Vec with type name S

pub fn set_many<S: AsRef<str>, T: Sized + Serialize>(
    &mut self,
    values: Vec<(S, T)>
)
[src]

pub fn set_many_as<S: AsRef<str>, T: Sized + Serialize>(
    &mut self,
    values: Vec<(S, S, T)>
)
[src]

pub fn get<S: AsRef<str>>(&self, key: S) -> Option<&BvObject>[src]

Retrieve a BvObject

pub fn get_value<T: DeserializeOwned>(&self, key: &str) -> T[src]

Retrieve and deserialize a value to T

pub fn get_tuple<S: AsRef<str>>(&mut self, key: S) -> Option<BvTuple<'_>>[src]

Retrieve a value as BvTuple

pub fn get_str<S: AsRef<str>>(&mut self, key: S) -> BvStr<'_>[src]

Retrieve a value as BvStr

pub fn del<S: AsRef<str>>(&mut self, key: S) -> Option<BvObject>[src]

Delete key and return the deleted object

Trait Implementations

impl<KV> BytesFilter for KvDb<KV> where
    KV: KvInterface<Key = BvString, Value = BvObject>,
    &'a KV: IntoIterator<Item = (&'a BvString, &'a BvObject)>, 
[src]

impl<KV: KvInterface<Key = BvString, Value = BvObject>> BytesSearch for KvDb<KV> where
    KV: KvInterface<Key = BvString, Value = BvObject>,
    &'a KV: IntoIterator<Item = (&'a BvString, &'a BvObject)>, 
[src]

impl<KV: Default + KvInterface> Default for KvDb<KV>[src]

Auto Trait Implementations

impl<KV> RefUnwindSafe for KvDb<KV> where
    KV: RefUnwindSafe

impl<KV> Send for KvDb<KV> where
    KV: Send

impl<KV> Sync for KvDb<KV> where
    KV: Sync

impl<KV> Unpin for KvDb<KV> where
    KV: Unpin

impl<KV> UnwindSafe for KvDb<KV> where
    KV: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.