Struct cw_storage_plus::Map
source · [−]pub struct Map<'a, K, T> { /* private fields */ }
Implementations
sourceimpl<'a, K, T> Map<'a, K, T> where
T: Serialize + DeserializeOwned,
K: PrimaryKey<'a>,
impl<'a, K, T> Map<'a, K, T> where
T: Serialize + DeserializeOwned,
K: PrimaryKey<'a>,
pub fn key(&self, k: K) -> Path<T>
pub fn prefix(&self, p: K::Prefix) -> Prefix<T>
pub fn sub_prefix(&self, p: K::SubPrefix) -> Prefix<T>
pub fn save(&self, store: &mut dyn Storage, k: K, data: &T) -> StdResult<()>
pub fn remove(&self, store: &mut dyn Storage, k: K)
sourcepub fn load(&self, store: &dyn Storage, k: K) -> StdResult<T>
pub fn load(&self, store: &dyn Storage, k: K) -> StdResult<T>
load will return an error if no data is set at the given key, or on parse error
sourcepub fn may_load(&self, store: &dyn Storage, k: K) -> StdResult<Option<T>>
pub fn may_load(&self, store: &dyn Storage, k: K) -> StdResult<Option<T>>
may_load will parse the data stored at the key if present, returns Ok(None) if no data there. returns an error on issues parsing
sourcepub fn has(&self, store: &dyn Storage, k: K) -> bool
pub fn has(&self, store: &dyn Storage, k: K) -> bool
has returns true or false if any data is at this key, without parsing or interpreting the contents.
sourcepub fn update<A, E>(
&self,
store: &mut dyn Storage,
k: K,
action: A
) -> Result<T, E> where
A: FnOnce(Option<T>) -> Result<T, E>,
E: From<StdError>,
pub fn update<A, E>(
&self,
store: &mut dyn Storage,
k: K,
action: A
) -> Result<T, E> where
A: FnOnce(Option<T>) -> Result<T, E>,
E: From<StdError>,
Loads the data, perform the specified action, and store the result in the database. This is shorthand for some common sequences, which may be useful.
If the data exists, action(Some(value))
is called. Otherwise action(None)
is called.
sourceimpl<'a, K, T> Map<'a, K, T> where
T: Serialize + DeserializeOwned,
K: PrimaryKey<'a>,
K::SubPrefix: EmptyPrefix,
impl<'a, K, T> Map<'a, K, T> where
T: Serialize + DeserializeOwned,
K: PrimaryKey<'a>,
K::SubPrefix: EmptyPrefix,
pub fn range<'c>(
&self,
store: &'c dyn Storage,
min: Option<Bound>,
max: Option<Bound>,
order: Order
) -> Box<dyn Iterator<Item = StdResult<Pair<T>>> + 'c> where
T: 'c,
pub fn keys<'c>(
&self,
store: &'c dyn Storage,
min: Option<Bound>,
max: Option<Bound>,
order: Order
) -> Box<dyn Iterator<Item = Vec<u8>> + 'c> where
T: 'c,
Trait Implementations
Auto Trait Implementations
impl<'a, K, T> RefUnwindSafe for Map<'a, K, T> where
K: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, K, T> Send for Map<'a, K, T> where
K: Send,
T: Send,
impl<'a, K, T> Sync for Map<'a, K, T> where
K: Sync,
T: Sync,
impl<'a, K, T> Unpin for Map<'a, K, T> where
K: Unpin,
T: Unpin,
impl<'a, K, T> UnwindSafe for Map<'a, K, T> where
K: UnwindSafe,
T: UnwindSafe,
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