Trait StateCodec

Source
pub trait StateCodec {
    type KeyCodec;
    type ValueCodec;

    // Required methods
    fn key_codec(&self) -> &Self::KeyCodec;
    fn value_codec(&self) -> &Self::ValueCodec;
}
Expand description

A trait for types that can serialize keys and values, as well as deserializing values for storage access.

§Type bounds

There are no type bounds on StateCodec::KeyCodec and StateCodec::ValueCodec, so they can be any type at well. That said, you’ll find many APIs require these two to implement StateKeyCodec and StateValueCodec respectively.

Required Associated Types§

Source

type KeyCodec

The codec used to serialize keys. See StateKeyCodec.

Source

type ValueCodec

The codec used to serialize and deserialize values. See StateValueCodec.

Required Methods§

Source

fn key_codec(&self) -> &Self::KeyCodec

Returns a reference to the type’s key codec.

Source

fn value_codec(&self) -> &Self::ValueCodec

Returns a reference to the type’s value codec.

Implementors§