pub trait PrimaryKey<'a>: Clone {
    type Prefix: Prefixer<'a>;
    type SubPrefix: Prefixer<'a>;
    type Suffix: KeyDeserialize;
    type SuperSuffix: KeyDeserialize;

    // Required method
    fn key(&self) -> Vec<Key<'_>>;

    // Provided methods
    fn joined_key(&self) -> Vec<u8> { ... }
    fn joined_extra_key(&self, key: &[u8]) -> Vec<u8> { ... }
}
Expand description

PrimaryKey needs to be implemented for types that want to be a Map (or Map-like) key, or part of a key.

In particular, it defines a series of types that help iterating over parts of a (composite) key:

Prefix: Prefix is eager. That is, except for empty keys, it’s always “one less” than the full key. Suffix: Suffix is the complement of prefix. SubPrefix: Sub-prefix is “one less” than prefix. SuperSuffix: Super-suffix is “one more” than suffix. The complement of sub-prefix.

By example, for a 2-tuple (T, U):

T: Prefix. U: Suffix. (): Sub-prefix. (T, U): Super-suffix.

SubPrefix and SuperSuffix only make real sense in the case of triples. Still, they need to be consistently defined for all types.

Required Associated Types§

source

type Prefix: Prefixer<'a>

These associated types need to implement Prefixer, so that they can be useful arguments for prefix(), sub_prefix(), and their key-deserializable variants.

source

type SubPrefix: Prefixer<'a>

source

type Suffix: KeyDeserialize

These associated types need to implement KeyDeserialize, so that they can be returned from range_de() and friends.

source

type SuperSuffix: KeyDeserialize

Required Methods§

source

fn key(&self) -> Vec<Key<'_>>

returns a slice of key steps, which can be optionally combined

Provided Methods§

source

fn joined_key(&self) -> Vec<u8>

source

fn joined_extra_key(&self, key: &[u8]) -> Vec<u8>

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'a> PrimaryKey<'a> for &'a str

§

type Prefix = ()

§

type SubPrefix = ()

§

type Suffix = &'a str

§

type SuperSuffix = &'a str

source§

fn key(&self) -> Vec<Key<'_>>

source§

impl<'a> PrimaryKey<'a> for &'a [u8]

§

type Prefix = ()

§

type SubPrefix = ()

§

type Suffix = &'a [u8]

§

type SuperSuffix = &'a [u8]

source§

fn key(&self) -> Vec<Key<'_>>

source§

impl<'a> PrimaryKey<'a> for i8

§

type Prefix = ()

§

type SubPrefix = ()

§

type Suffix = i8

§

type SuperSuffix = i8

source§

fn key(&self) -> Vec<Key<'_>>

source§

impl<'a> PrimaryKey<'a> for i16

§

type Prefix = ()

§

type SubPrefix = ()

§

type Suffix = i16

§

type SuperSuffix = i16

source§

fn key(&self) -> Vec<Key<'_>>

source§

impl<'a> PrimaryKey<'a> for i32

§

type Prefix = ()

§

type SubPrefix = ()

§

type Suffix = i32

§

type SuperSuffix = i32

source§

fn key(&self) -> Vec<Key<'_>>

source§

impl<'a> PrimaryKey<'a> for i64

§

type Prefix = ()

§

type SubPrefix = ()

§

type Suffix = i64

§

type SuperSuffix = i64

source§

fn key(&self) -> Vec<Key<'_>>

source§

impl<'a> PrimaryKey<'a> for i128

§

type Prefix = ()

§

type SubPrefix = ()

§

type Suffix = i128

§

type SuperSuffix = i128

source§

fn key(&self) -> Vec<Key<'_>>

source§

impl<'a> PrimaryKey<'a> for u8

§

type Prefix = ()

§

type SubPrefix = ()

§

type Suffix = u8

§

type SuperSuffix = u8

source§

fn key(&self) -> Vec<Key<'_>>

source§

impl<'a> PrimaryKey<'a> for u16

§

type Prefix = ()

§

type SubPrefix = ()

§

type Suffix = u16

§

type SuperSuffix = u16

source§

fn key(&self) -> Vec<Key<'_>>

source§

impl<'a> PrimaryKey<'a> for u32

§

type Prefix = ()

§

type SubPrefix = ()

§

type Suffix = u32

§

type SuperSuffix = u32

source§

fn key(&self) -> Vec<Key<'_>>

source§

impl<'a> PrimaryKey<'a> for u64

§

type Prefix = ()

§

type SubPrefix = ()

§

type Suffix = u64

§

type SuperSuffix = u64

source§

fn key(&self) -> Vec<Key<'_>>

source§

impl<'a> PrimaryKey<'a> for u128

§

type Prefix = ()

§

type SubPrefix = ()

§

type Suffix = u128

§

type SuperSuffix = u128

source§

fn key(&self) -> Vec<Key<'_>>

source§

impl<'a> PrimaryKey<'a> for ()

§

type Prefix = ()

§

type SubPrefix = ()

§

type Suffix = ()

§

type SuperSuffix = ()

source§

fn key(&self) -> Vec<Key<'_>>

source§

impl<'a> PrimaryKey<'a> for String

§

type Prefix = ()

§

type SubPrefix = ()

§

type Suffix = String

§

type SuperSuffix = String

source§

fn key(&self) -> Vec<Key<'_>>

source§

impl<'a> PrimaryKey<'a> for Vec<u8>

§

type Prefix = ()

§

type SubPrefix = ()

§

type Suffix = Vec<u8>

§

type SuperSuffix = Vec<u8>

source§

fn key(&self) -> Vec<Key<'_>>

source§

impl<'a> PrimaryKey<'a> for Addr

owned variant.

§

type Prefix = ()

§

type SubPrefix = ()

§

type Suffix = Addr

§

type SuperSuffix = Addr

source§

fn key(&self) -> Vec<Key<'_>>

source§

impl<'a, T> PrimaryKey<'a> for &'a T
where T: PrimaryKey<'a>,

§

type Prefix = <T as PrimaryKey<'a>>::Prefix

§

type SubPrefix = <T as PrimaryKey<'a>>::SubPrefix

§

type Suffix = <T as PrimaryKey<'a>>::Suffix

§

type SuperSuffix = <T as PrimaryKey<'a>>::SuperSuffix

source§

fn key(&self) -> Vec<Key<'_>>

source§

impl<'a, T: PrimaryKey<'a> + Prefixer<'a> + KeyDeserialize, U: PrimaryKey<'a> + KeyDeserialize> PrimaryKey<'a> for (T, U)

§

type Prefix = T

§

type SubPrefix = ()

§

type Suffix = U

§

type SuperSuffix = (T, U)

source§

fn key(&self) -> Vec<Key<'_>>

source§

impl<'a, T: PrimaryKey<'a> + Prefixer<'a>, U: PrimaryKey<'a> + Prefixer<'a> + KeyDeserialize, V: PrimaryKey<'a> + KeyDeserialize> PrimaryKey<'a> for (T, U, V)

§

type Prefix = (T, U)

§

type SubPrefix = T

§

type Suffix = V

§

type SuperSuffix = (U, V)

source§

fn key(&self) -> Vec<Key<'_>>

source§

impl<'a, const N: usize> PrimaryKey<'a> for [u8; N]

§

type Prefix = ()

§

type SubPrefix = ()

§

type Suffix = [u8; N]

§

type SuperSuffix = [u8; N]

source§

fn key(&self) -> Vec<Key<'_>>

Implementors§