Skip to main content

PrimaryKey

Trait PrimaryKey 

Source
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>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl PrimaryKey<'_> for ()

Source§

impl PrimaryKey<'_> for Addr

owned variant.

Source§

impl PrimaryKey<'_> for String

Source§

impl PrimaryKey<'_> for Vec<u8>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

type Prefix = ()

Source§

type SubPrefix = ()

Source§

type Suffix = &'a [u8]

Source§

type SuperSuffix = &'a [u8]

Source§

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

Source§

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

Source§

impl<'a> PrimaryKey<'a> for Int64

Source§

impl<'a> PrimaryKey<'a> for Int128

Source§

impl<'a> PrimaryKey<'a> for Uint64

Source§

impl<'a> PrimaryKey<'a> for Uint128

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§