[−][src]Struct sfkv::Store
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]
&'a self,
key: &str
) -> Result<Option<T>, Error<B::Error>>
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]
&mut self,
key: &str,
value: V
) -> Result<(), Error<B::Error>>
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]
&mut self,
key: &str,
value: &T,
value_buf: V
) -> Result<(), Error<B::Error>> where
T: Serialize,
V: AsMut<[u8]>,
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]
B: Send,
impl<B> Sync for Store<B> where
B: Sync,
[src]
B: Sync,
impl<B> Unpin for Store<B> where
B: Unpin,
[src]
B: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,