Trait Key

Source
pub trait Key<const N: usize>:
    Eq
    + PartialEq
    + Copy
    + Clone
    + Hash
    + Deref<Target = InternalKey<N>> {
    type Error;

    // Required methods
    fn as_slice(&self) -> &[u8] ;
    fn try_from_bytes(bytes: &[u8]) -> Result<Self, Self::Error>;

    // Provided method
    fn to_vec(&self) -> Vec<u8>  { ... }
}
Expand description

This trait is map keys to / from the users key space into a finite key space used internally. This space is the set of all N-byte arrays where N < 2^32

Required Associated Types§

Source

type Error

The error type for failed mappings

Required Methods§

Source

fn as_slice(&self) -> &[u8]

This should map from the internal key space back into the user’s key space

Source

fn try_from_bytes(bytes: &[u8]) -> Result<Self, Self::Error>

This should map from the user’s key space into the internal keyspace

Provided Methods§

Source

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

This should map from the internal key space back into the user’s key space

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Key<32> for Hash