KVStore

Struct KVStore 

Source
pub struct KVStore<A, const BUCKETS: usize, const SLOTS: usize>
where A: StoreAdapter,
{ /* private fields */ }

Implementations§

Source§

impl<E, A, const BUCKETS: usize, const SLOTS: usize> KVStore<A, BUCKETS, SLOTS>
where A: StoreAdapter<Error = E>,

Source

pub fn open( adapter: A, cfg: StoreConfig, create_new: bool, ) -> Result<Self, Error<E>>

Source

pub fn create(adapter: A, cfg: StoreConfig) -> Result<Self, Error<E>>

Source

pub fn adapter(&mut self) -> &mut A

Source

pub fn close(self) -> A

Source

pub fn reset(&mut self) -> Result<(), Error<E>>

Source

pub fn alloc( &mut self, key: &[u8], val_len: usize, fill_with: Option<u8>, ) -> Result<Bucket, Error<E>>

Source

pub fn insert(&mut self, key: &[u8], val: &[u8]) -> Result<Bucket, Error<E>>

Source

pub fn append(&mut self, key: &[u8], val: &[u8]) -> Result<Bucket, Error<E>>

Source

pub fn patch( &mut self, key: &[u8], offset: usize, patch: &[u8], ) -> Result<Bucket, Error<E>>

Source

pub fn load(&mut self, key: &[u8], buf: &mut [u8]) -> Result<Bucket, Error<E>>

Source

pub fn load_slice<'a>( &mut self, key: &[u8], buf: &'a mut [u8], ) -> Result<&'a [u8], Error<E>>

Source

pub fn load_str<'a>( &mut self, key: &[u8], buf: &'a mut [u8], ) -> Result<&'a str, Error<E>>

Source

pub fn load_at( &mut self, key: &[u8], buf: &mut [u8], offset: usize, ) -> Result<Bucket, Error<E>>

Source

pub fn erase(&mut self, key: &[u8], fill_with: u8) -> Result<(), Error<E>>

Source

pub fn remove(&mut self, key: &[u8]) -> Result<(), Error<E>>

Source

pub fn keys(&mut self) -> KeysIterator<'_, '_, A, BUCKETS, SLOTS>

Source

pub fn keys_with_prefix<'a>( &mut self, pat: &'a [u8], ) -> KeysIterator<'_, 'a, A, BUCKETS, SLOTS>

Source

pub fn exists(&mut self, key: &[u8]) -> Result<bool, Error<E>>

Source

pub fn lookup(&mut self, key: &[u8]) -> Result<Bucket, Error<E>>

Source§

impl<E, A, const BUCKETS: usize, const SLOTS: usize> KVStore<A, BUCKETS, SLOTS>
where A: StoreAdapter<Error = E>,

Source

pub fn insert_val<T: Serialize, const N: usize>( &mut self, id: &[u8], val: &T, ) -> Result<Bucket, Error<E>>

Source

pub fn load_val<T: DeserializeOwned, const N: usize>( &mut self, id: &[u8], ) -> Result<T, Error<E>>

Auto Trait Implementations§

§

impl<A, const BUCKETS: usize, const SLOTS: usize> Freeze for KVStore<A, BUCKETS, SLOTS>
where A: Freeze,

§

impl<A, const BUCKETS: usize, const SLOTS: usize> RefUnwindSafe for KVStore<A, BUCKETS, SLOTS>
where A: RefUnwindSafe,

§

impl<A, const BUCKETS: usize, const SLOTS: usize> Send for KVStore<A, BUCKETS, SLOTS>
where A: Send,

§

impl<A, const BUCKETS: usize, const SLOTS: usize> Sync for KVStore<A, BUCKETS, SLOTS>
where A: Sync,

§

impl<A, const BUCKETS: usize, const SLOTS: usize> Unpin for KVStore<A, BUCKETS, SLOTS>
where A: Unpin,

§

impl<A, const BUCKETS: usize, const SLOTS: usize> UnwindSafe for KVStore<A, BUCKETS, SLOTS>
where A: UnwindSafe,

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.