DocDb

Struct DocDb 

Source
pub struct DocDb { /* private fields */ }

Implementations§

Source§

impl DocDb

Source

pub fn new<P: AsRef<Path>>( db_path: P, dump_policy: DumpPolicy, serialize_method: SerializationMethod, ) -> Self

Source

pub fn new_json<P: AsRef<Path>>(db_path: P, dump_policy: DumpPolicy) -> Self

Source

pub fn load<P: AsRef<Path>>( db_path: P, dump_policy: DumpPolicy, ser_method: SerializationMethod, ) -> Result<DocDb>

Source

pub fn load_read_only<P: AsRef<Path>>( db_path: P, serialization_method: SerializationMethod, ) -> Result<DocDb>

Source

pub fn load_json<P: AsRef<Path>>( db_path: P, dump_policy: DumpPolicy, ) -> Result<Self>

Source

pub fn dump(&mut self) -> Result<()>

Source

pub fn dump_now(&mut self) -> Result<()>

Source

pub fn set<T: Serialize>(&mut self, key: &str, val: &T) -> Result<()>

Source

pub fn get<T: DeserializeOwned>(&self, key: &str) -> Option<T>

Source

pub fn exist(&self, key: &str) -> bool

Source

pub fn get_all_keys(&self) -> Vec<String>

Get a vector of all the keys in the DB.

The keys returned in the vector are not references to the actual key string objects but rather a clone of them.

Source

pub fn total_nums(&self) -> usize

Get the total number of keys in the DB.

Source

pub fn rem(&mut self, key: &str) -> Result<bool>

Source

pub fn iter(&self) -> DocDbIterator<'_>

Trait Implementations§

Source§

impl Drop for DocDb

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for DocDb

§

impl RefUnwindSafe for DocDb

§

impl Send for DocDb

§

impl Sync for DocDb

§

impl Unpin for DocDb

§

impl UnwindSafe for DocDb

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.