Struct cw_storage_plus::IndexedMap [−][src]
pub struct IndexedMap<'a, K, T, I> where
K: PrimaryKey<'a>,
T: Serialize + DeserializeOwned + Clone,
I: IndexList<T>, {
pub idx: I,
// some fields omitted
}
Expand description
IndexedMap
works like a Map
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> IndexedMap<'a, K, T, I> where
K: PrimaryKey<'a>,
T: Serialize + DeserializeOwned + Clone,
I: IndexList<T>,
impl<'a, K, T, I> IndexedMap<'a, K, T, I> where
K: PrimaryKey<'a>,
T: Serialize + DeserializeOwned + Clone,
I: IndexList<T>,
impl<'a, K, T, I> IndexedMap<'a, K, T, I> where
K: PrimaryKey<'a>,
T: Serialize + DeserializeOwned + Clone,
I: IndexList<T>,
impl<'a, K, T, I> IndexedMap<'a, K, T, I> where
K: PrimaryKey<'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
impl<'a, K, T, I> IndexedMap<'a, K, T, I> where
K: PrimaryKey<'a>,
T: Serialize + DeserializeOwned + Clone,
I: IndexList<T>,
impl<'a, K, T, I> IndexedMap<'a, K, T, I> where
K: PrimaryKey<'a>,
T: Serialize + DeserializeOwned + Clone,
I: IndexList<T>,
impl<'a, K, T, I> IndexedMap<'a, K, T, I> where
K: PrimaryKey<'a>,
T: Serialize + DeserializeOwned + Clone,
I: IndexList<T>,
impl<'a, K, T, I> IndexedMap<'a, K, T, I> where
K: PrimaryKey<'a>,
T: Serialize + DeserializeOwned + Clone,
I: IndexList<T>,
While range_raw
over a prefix
fixes the prefix to one element and iterates over the
remaining, prefix_range_raw
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.
impl<'a, K, T, I> IndexedMap<'a, K, T, I> where
T: Serialize + DeserializeOwned + Clone,
K: PrimaryKey<'a>,
I: IndexList<T>,
impl<'a, K, T, I> IndexedMap<'a, K, T, I> where
T: Serialize + DeserializeOwned + Clone,
K: PrimaryKey<'a>,
I: IndexList<T>,
impl<'a, K, T, I> IndexedMap<'a, K, T, I> where
T: Serialize + DeserializeOwned + Clone,
K: PrimaryKey<'a> + KeyDeserialize,
I: IndexList<T>,
impl<'a, K, T, I> IndexedMap<'a, K, T, I> where
T: Serialize + DeserializeOwned + Clone,
K: PrimaryKey<'a> + KeyDeserialize,
I: IndexList<T>,
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.