[][src]Struct keratin::Collection

pub struct Collection { /* fields omitted */ }

Represents a collection of documents.

It is the main API for data managment for Keratin.

Implementations

impl Collection[src]

pub fn get(&mut self, k: &str) -> Option<&Entry>[src]

Returns an entry of the database given the respective key, or None if the key corresponds to no known entries

pub fn insert(&mut self, key: &str, entry: &str) -> Result<(), Errors>[src]

Insert an entry into the database given an Entry

Note

This does not cache the entry automaticaly

pub fn delete(&mut self, query: &str) -> Result<(), Errors>[src]

Delete a entry in the database given the key.

This deletes from both the cache and non-volatile storage.

Note

In the future this will use a query string to find what multiple elements to delete

Return

Returns an Error EntryNotFound if the key does not match any entry

pub fn modify(&mut self, key: &str, new_entry: &str) -> Result<(), Errors>[src]

pub fn new(self, truncate: bool) -> Result<Collection, Errors>[src]

A function to create a new Keratin db from scratch for a fast setup.

The config file keratin.toml is created with the default options. If it already exists, the config file.

Arguments

Truncate: if it is TRUE, this function wipes every document in db/data/ along with truncating the mapped keys file.

Panics

This fuction uses the enviroment variable CARGO_MANIFEST_DIR, so this will only work when running your project using cargo, else it will panic. If you're using planning in using Keratin in production use configure() instead

pub fn configure(path: Option<&str>) -> Collection[src]

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)

Attention

USE ONLY ABSOLUTE PATHS!!!

Use of the None Option is unstable

Errors

This returns an error if the config file is not found OR if the folder doesn't have the right permitions

pub fn cache_entries(&mut self)[src]

Trait Implementations

impl Clone for Collection[src]

impl Debug for Collection[src]

Auto Trait Implementations

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,