Skip to main content

Store

Struct Store 

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

Store is similar to VBuckMap, but allows records of any length.

insert, get, remove and iter give access to keyed records. Small keyed records ( < 255 bytes ) are fast to store and access, large records are slower. For example iterating over 64K small records could take 1 milli-sec, but 90 milli-sec for large records. Insert performance is improved if key length is known and small ( VKey::len ).

Keyed records are mutable in the sense that they can be removed then re-inserted with the same key.

store, fetch and delete give access to data where the key is an u64 id chosen by the Store. This can be used to reduce the size of a keyed record by storing large parts separately.

Implementations§

Source§

impl Store

Source

pub fn new(ps: &mut PageSet) -> Self

Start a new store.

Source

pub fn insert<K: VKey>(&mut self, key: &K, user_data: &[u8], ps: &mut PageSet)

Insert user_data, must not be a duplicate key ( but this is not checked ).

Source

pub fn get<K: VKey>(&mut self, key: &K, ps: &mut PageSet) -> Option<SData>

Get data for specified key, returns SData, or None if key not found.

Source

pub fn remove<K: VKey>(&mut self, key: &K, ps: &mut PageSet) -> bool

Remove specified key.

Source

pub fn iter<'a>(&'a self, ps: &mut PageSet) -> StoreIter<'a>

Get iterator that returns all records (rows).

Source

pub fn store(&mut self, user_data: &[u8], ps: &mut PageSet) -> u64

Store arbitrary size data, returns id. Use fetch to get it back.

Source

pub fn fetch(&self, id: u64, len: usize, ps: &mut PageSet) -> LVec<u8>

Fetch stored data, len must not exceed len of stored user_data.

Source

pub fn delete(&mut self, id: u64, len: usize, ps: &mut PageSet)

Delete stored data, len must be equal to original len of stored user_data.

Source

pub fn delete_all(&mut self, ps: &mut PageSet)

Delete everything, Store is no longer usable.

Trait Implementations§

Source§

impl Debug for Store

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Store

§

impl RefUnwindSafe for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

§

impl UnwindSafe for Store

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.