pub trait Key<'k>: Clone + Debug + Send + Sync {
    type Error: AnyError;

    const LENGTH: Option<usize>;

    fn as_ord_bytes(&'k self) -> Result<Cow<'k, [u8]>, Self::Error>;
fn from_ord_bytes(bytes: &'k [u8]) -> Result<Self, Self::Error>; fn first_value() -> Result<Self, NextValueError> { ... }
fn next_value(&self) -> Result<Self, NextValueError> { ... } }
Expand description

A trait that enables a type to convert itself into a memcmp-compatible sequence of bytes.

Associated Types

The error type that can be produced by either serialization or deserialization.

Associated Constants

The size of the key, if constant. If this type doesn’t produce the same number of bytes for each value, this should be None.

Required methods

Convert self into a Cow<[u8]> containing bytes that are able to be compared via memcmp in a way that is comptaible with its own Ord implementation.

Deserialize a sequence of bytes previously encoded with Self::as_ord_bytes.

Provided methods

Return the first value in sequence for this type. Not all types implement this.

Return the next value in sequence for this type. Not all types implement this. Instead of wrapping/overflowing, None should be returned.

Implementations on Foreign Types

Panics

Panics if T::into_big_endian_bytes returns an empty IVec.

Implementors