[][src]Struct sfkv::Store

pub struct Store<B: StoreBackend> { /* fields omitted */ }

Simple Flash Key Value Store

Implementations

impl<B: StoreBackend> Store<B>[src]

pub fn new(backend: B) -> Self[src]

wrap a StoreBackend into a store

pub fn read(&self, key: &str) -> Result<Option<&[u8]>, ReadError>[src]

read from key

pub fn read_str(&self, key: &str) -> Result<Option<&str>, ReadError>[src]

read from key, decode UTF-8

pub fn read_value<'a, T: Deserialize<'a>>(
    &'a self,
    key: &str
) -> Result<Option<T>, Error<B::Error>>
[src]

read from key, decode with postcard

pub fn get_bytes_used(&self) -> Result<usize, ReadError>[src]

how many bytes are currently used

equally, offset of free space

pub fn write<V: AsRef<[u8]>>(
    &mut self,
    key: &str,
    value: V
) -> Result<(), Error<B::Error>>
[src]

store a buffer value at key

pub fn write_value<T, V>(
    &mut self,
    key: &str,
    value: &T,
    value_buf: V
) -> Result<(), Error<B::Error>> where
    T: Serialize,
    V: AsMut<[u8]>, 
[src]

encode with postcard, write at key

pub fn remove(&mut self, key: &str) -> Result<(), Error<B::Error>>[src]

store a 0-byte tombstone value at key

pub fn erase(&mut self) -> Result<(), WriteError<B::Error>>[src]

invokes erase on the backend (this is no compaction!)

Auto Trait Implementations

impl<B> Send for Store<B> where
    B: Send
[src]

impl<B> Sync for Store<B> where
    B: Sync
[src]

impl<B> Unpin for Store<B> where
    B: Unpin
[src]

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> Same<T> for T

type Output = T

Should always be Self

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.