Struct cw_storage_plus::UniqueIndex [−][src]
pub struct UniqueIndex<'a, IK, T, PK = ()> { /* fields omitted */ }
Expand description
UniqueIndex stores (namespace, index_name, idx_value) -> {key, value} Allows one value per index (i.e. unique) and copies pk and data The optional PK type defines the type of Primary Key deserialization.
Implementations
Create a new UniqueIndex
idx_fn - lambda creating index key from index value idx_namespace - prefix for the index value
Example:
use cw_storage_plus::UniqueIndex;
struct Data {
pub name: String,
pub age: u32,
}
UniqueIndex::<_, _, ()>::new(|d: &Data| d.age, "data__age");
impl<'a, IK, T, PK> UniqueIndex<'a, IK, T, PK> where
T: Serialize + DeserializeOwned + Clone,
IK: PrimaryKey<'a>,
impl<'a, IK, T, PK> UniqueIndex<'a, IK, T, PK> where
T: Serialize + DeserializeOwned + Clone,
IK: PrimaryKey<'a>,
impl<'a, IK, T, PK> UniqueIndex<'a, IK, T, PK> where
T: Serialize + DeserializeOwned + Clone,
IK: PrimaryKey<'a>,
impl<'a, IK, T, PK> UniqueIndex<'a, IK, T, PK> where
T: Serialize + DeserializeOwned + Clone,
IK: PrimaryKey<'a>,
impl<'a, IK, T, PK> UniqueIndex<'a, IK, T, PK> where
PK: PrimaryKey<'a> + KeyDeserialize,
T: Serialize + DeserializeOwned + Clone,
IK: PrimaryKey<'a>,
impl<'a, IK, T, PK> UniqueIndex<'a, IK, T, PK> where
PK: PrimaryKey<'a> + KeyDeserialize,
T: Serialize + DeserializeOwned + Clone,
IK: PrimaryKey<'a>,
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.