The KeyDeserialize trait which is required for a type that would like to be a key for a Map is private in the cw_storage_plus::de module. This makes implementing custom map keys and functions that are generic over the map key type not possible.
For example, a generic function which lists all of the keys in a Map can't be implemented because the trait is private:
fn list_items<'a, K, V>(
deps: Deps,
map: Map<K, V>,
start_at: Option<K>,
limit: Option<u64>,
) -> StdResult<Vec<K>>
where
K: cw_storage_plus::Bounder<'a>
+ cw_storage_plus::PrimaryKey<'a>
+ cw_storage_plus::de::KeyDeserialize,
V: serde::de::DeserializeOwned + serde::Serialize,
{
let items = map.keys(
deps.storage,
start_at.map(Bound::inclusive),
None,
cosmwasm_std::Order::Descending,
);
match limit {
Some(limit) => Ok(items.take(limit as usize).collect::<Result<Vec<K>, _>>()?),
None => Ok(items.collect::<Result<Vec<K>, _>>()?),
}
}
Would be really cool to be able to do this. :)
The
KeyDeserializetrait which is required for a type that would like to be a key for aMapis private in thecw_storage_plus::demodule. This makes implementing custom map keys and functions that are generic over the map key type not possible.For example, a generic function which lists all of the keys in a
Mapcan't be implemented because the trait is private:Would be really cool to be able to do this. :)