pub trait StateKeyCodec<K> {
// Required method
fn encode_key(&self, key: &K) -> Vec<u8> ⓘ;
}
Expand description
A trait for types that can serialize keys for storage access.
Note that, unlike StateValueCodec
, this trait does not provide
deserialization logic as it’s not needed nor supported.
Required Methods§
Sourcefn encode_key(&self, key: &K) -> Vec<u8> ⓘ
fn encode_key(&self, key: &K) -> Vec<u8> ⓘ
Serializes a key into a bytes vector.
§Determinism
All implementations of this trait method MUST provide deterministic serialization behavior:
- Equal (as defined by
Eq
) values MUST be serialized to the same byte sequence. - The serialization result MUST NOT depend on the compilation target and other runtime environment parameters. If that were the case, zkVM code and native code wouldn’t produce the same keys.