Struct ark_api::storage::AsyncStore
source · [−]pub struct AsyncStore { /* private fields */ }
Expand description
Simple key-value data store which loads values in a lazy way.
Implementations
sourceimpl AsyncStore
impl AsyncStore
sourcepub fn open(realm: StoreRealm, name: StoreName) -> Self
pub fn open(realm: StoreRealm, name: StoreName) -> Self
Open an async store for a specific realm and name.
If the store doesn’t exist, locally or globally, it will be automatically created.
Names of stores is limited to max 32 characters and can only be alphanumeric or dash or underscore.
Global stores
Note that for StoreRealm::Global
this will synchronize all the keys during the initial
opening. Prefer to call this early in module initialization.
Also the store name is global, so be precise and unique in your naming to not pollute or collide other stores.
Panics
This function panics if a store could not be opened for the given name.
sourcepub fn get<K: AsRef<[u8]>>(&self, key: K) -> LazyGetHandleⓘNotable traits for LazyGetHandleimpl Future for LazyGetHandle type Output = Option<Vec<u8>>;
pub fn get<K: AsRef<[u8]>>(&self, key: K) -> LazyGetHandleⓘNotable traits for LazyGetHandleimpl Future for LazyGetHandle type Output = Option<Vec<u8>>;
Get the value of a key, if available; returns a handle that will later resolve to this value, if present.
sourcepub fn insert<K: AsRef<[u8]>, V: AsRef<[u8]>>(&mut self, key: K, value: V)
pub fn insert<K: AsRef<[u8]>, V: AsRef<[u8]>>(&mut self, key: K, value: V)
Insert a key
If the key already exists in the store, it will be overwritten
sourcepub fn keys(&self) -> Keys
pub fn keys(&self) -> Keys
Get a list of all keys currently in the store.
Note that this is a snapshot from the time of the call, for stores using StoreRealm::Global
there
is a chance keys can be removed while one is iterating through this list, and new keys can also
be added or the value of the keys changed
This can be bit expensive operation for stores that contain a lot of keys
Trait Implementations
sourceimpl Clone for AsyncStore
impl Clone for AsyncStore
sourcefn clone(&self) -> AsyncStore
fn clone(&self) -> AsyncStore
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Drop for AsyncStore
impl Drop for AsyncStore
sourceimpl PartialEq<AsyncStore> for AsyncStore
impl PartialEq<AsyncStore> for AsyncStore
sourcefn eq(&self, other: &AsyncStore) -> bool
fn eq(&self, other: &AsyncStore) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
impl StructuralPartialEq for AsyncStore
Auto Trait Implementations
impl RefUnwindSafe for AsyncStore
impl !Send for AsyncStore
impl !Sync for AsyncStore
impl Unpin for AsyncStore
impl UnwindSafe for AsyncStore
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more