[−][src]Trait exonum::storage::proof_map_index::HashedKey
A trait denoting that a certain storage value is suitable for use as a key for
ProofMapIndex
after hashing.
Warning: The implementation of the ProofMapKey.write_key()
method provided
by this trait is not efficient; it calculates the hash anew on each call.
Example
#[derive(ProtobufConvert)] #[exonum(pb = "exonum::proto::schema::doc_tests::Point")] struct Point { x: i32, y: i32, } impl Point { fn new(x: i32, y: i32) -> Self { Self { x, y } } } impl HashedKey for Point {} let mut fork = { let db = MemoryDB::new(); db.fork() }; let mut map = ProofMapIndex::new("index", &mut fork); map.put(&Point::new(3, -4), 5u32); assert_eq!(map.get(&Point::new(3, -4)), Some(5)); assert_eq!(map.get(&Point::new(3, 4)), None);