Struct cw_storage_plus::IndexedSnapshotMap [−][src]
pub struct IndexedSnapshotMap<'a, K, T, I> where
K: PrimaryKey<'a>,
T: Serialize + DeserializeOwned + Clone,
I: IndexList<T>, {
pub idx: I,
// some fields omitted
}
Expand description
IndexedSnapshotMap works like a SnapshotMap but has a secondary index
Fields
idx: I
This is meant to be read directly to get the proper types, like: map.idx.owner.items(…)
Implementations
impl<'a, K, T, I> IndexedSnapshotMap<'a, K, T, I> where
K: PrimaryKey<'a>,
T: Serialize + DeserializeOwned + Clone,
I: IndexList<T>,
impl<'a, K, T, I> IndexedSnapshotMap<'a, K, T, I> where
K: PrimaryKey<'a>,
T: Serialize + DeserializeOwned + Clone,
I: IndexList<T>,
impl<'a, K, T, I> IndexedSnapshotMap<'a, K, T, I> where
T: Serialize + DeserializeOwned + Clone,
K: PrimaryKey<'a> + Prefixer<'a>,
I: IndexList<T>,
impl<'a, K, T, I> IndexedSnapshotMap<'a, K, T, I> where
T: Serialize + DeserializeOwned + Clone,
K: PrimaryKey<'a> + Prefixer<'a>,
I: IndexList<T>,
impl<'a, K, T, I> IndexedSnapshotMap<'a, K, T, I> where
K: PrimaryKey<'a> + Prefixer<'a>,
T: Serialize + DeserializeOwned + Clone,
I: IndexList<T>,
impl<'a, K, T, I> IndexedSnapshotMap<'a, K, T, I> where
K: PrimaryKey<'a> + Prefixer<'a>,
T: Serialize + DeserializeOwned + Clone,
I: IndexList<T>,
save will serialize the model and store, returns an error on serialization issues. this must load the old value to update the indexes properly if you loaded the old value earlier in the same function, use replace to avoid needless db reads
replace writes data to key. old_data must be the current stored value (from a previous load) and is used to properly update the index. This is used by save, replace, and update and can be called directly if you want to optimize
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.
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