Struct cw_storage_plus::SnapshotMap [−][src]
pub struct SnapshotMap<'a, K, T> { /* fields omitted */ }
Expand description
Map that maintains a snapshots of one or more checkpoints. We can query historical data as well as current state. What data is snapshotted depends on the Strategy.
Implementations
impl<'a, K, T> SnapshotMap<'a, K, T> where
T: Serialize + DeserializeOwned + Clone,
K: PrimaryKey<'a> + Prefixer<'a>,
impl<'a, K, T> SnapshotMap<'a, K, T> where
T: Serialize + DeserializeOwned + Clone,
K: PrimaryKey<'a> + Prefixer<'a>,
impl<'a, K, T> SnapshotMap<'a, K, T> where
T: Serialize + DeserializeOwned + Clone,
K: PrimaryKey<'a> + Prefixer<'a> + KeyDeserialize,
impl<'a, K, T> SnapshotMap<'a, K, T> where
T: Serialize + DeserializeOwned + Clone,
K: PrimaryKey<'a> + Prefixer<'a> + KeyDeserialize,
load will return an error if no data is set at the given key, or on parse error
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
pub fn may_load_at_height(
&self,
store: &dyn Storage,
k: K,
height: u64
) -> StdResult<Option<T>>
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.
This is a bit more customized than needed to only read “old” value 1 time, not 2 per naive approach
impl<'a, K, T> SnapshotMap<'a, K, T> where
T: Serialize + DeserializeOwned + Clone,
K: PrimaryKey<'a> + Prefixer<'a> + KeyDeserialize,
impl<'a, K, T> SnapshotMap<'a, K, T> where
T: Serialize + DeserializeOwned + Clone,
K: PrimaryKey<'a> + Prefixer<'a> + KeyDeserialize,
impl<'a, K, T> SnapshotMap<'a, K, T> where
T: Serialize + DeserializeOwned,
K: PrimaryKey<'a> + KeyDeserialize,
impl<'a, K, T> SnapshotMap<'a, K, T> where
T: Serialize + DeserializeOwned,
K: PrimaryKey<'a> + KeyDeserialize,
While range
over a prefix
fixes the prefix to one element and iterates over the
remaining, prefix_range
accepts bounds for the lowest and highest elements of the
Prefix
itself, and iterates over those (inclusively or exclusively, depending on
PrefixBound
).
There are some issues that distinguish these two, and blindly casting to Vec<u8>
doesn’t
solve them.