Struct FileCave

Source
pub struct FileCave { /* private fields */ }
Expand description

A key-value store that stores keys in files.

This kv stores keys as files in a directory. Note that the directory must exist.

§Caveats

This kv has the following caveats:

  • It doesn’t perform a sync operation after every set/delete.
  • It doesn’t create multi-level directories, e.g., fi/le/name, to improve filesystem lookups.

Consider using it when you want to audit which keys are created using external tools, such as ls, cat.

Implementations§

Source§

impl FileCave

Source

pub fn new(dir: &Path) -> Result<Self, Error>

Create a new instance.

Check if the provided path is a directory and that it exists.

Trait Implementations§

Source§

impl Cave for FileCave

Source§

fn get(&self, name: &str) -> Res

Get a key by its name, and return its contents. Read more
Source§

fn set(&self, name: &str, data: &[u8]) -> Res

Create or update a key by its name.
Source§

fn delete(&self, name: &str) -> Res

Delete a key by its name. Read more
Source§

fn not_found(&self, name: &str) -> Res

A helper method to return an error for keys that could not be found.
Source§

impl Debug for FileCave

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.