pub struct Collection<'a, T> { /* private fields */ }
Expand description
Represents a collection of documents.
It is the main API for data managment for Keratin.
Implementations§
Source§impl<'a, T: Serialize + Clone + for<'de> Deserialize<'de>> Collection<'a, T>
impl<'a, T: Serialize + Clone + for<'de> Deserialize<'de>> Collection<'a, T>
Sourcepub fn get(&mut self, k: &str) -> Option<T>
pub fn get(&mut self, k: &str) -> Option<T>
Returns an entry of the database given the respective key, or None
if the key
corresponds to no known entries
pub fn truncate(&mut self) -> Result<()>
pub fn modify(&mut self, key: &str, new_entry: T) -> Result<()>
Sourcepub fn configure(
path: Option<&str>,
se: &'a dyn StorageEngine<T>,
) -> Result<Collection<'a, T>>
pub fn configure( path: Option<&str>, se: &'a dyn StorageEngine<T>, ) -> Result<Collection<'a, T>>
A function to initialize the collection using the path of a configuration file
§Arguments
-
path
- An Option with a Path. If this is None, Keratin will use the default config file path (eg.db/keratin.toml
) -
se
- TheStorage Engine
of the database. Right now onlyLocalFsStorage
is implemented into the crate, but in theory anything that implements theStorageEngine
trait could be passed as the parameter.
§Errors
This returns an error if the config file is not found OR if the folder doesn’t have the right permitions
pub fn iter_mut(&mut self) -> Result<IterMut<'_, String, T>>
Trait Implementations§
Source§impl<'a, T: Clone> Clone for Collection<'a, T>
impl<'a, T: Clone> Clone for Collection<'a, T>
Source§fn clone(&self) -> Collection<'a, T>
fn clone(&self) -> Collection<'a, T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<'a, T> Freeze for Collection<'a, T>
impl<'a, T> !RefUnwindSafe for Collection<'a, T>
impl<'a, T> !Send for Collection<'a, T>
impl<'a, T> !Sync for Collection<'a, T>
impl<'a, T> Unpin for Collection<'a, T>where
T: Unpin,
impl<'a, T> !UnwindSafe for Collection<'a, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more