Trait bonsaidb::core::key::KeyEncoding
pub trait KeyEncoding<K = Self>: Send + Sync {
type Error: AnyError;
const LENGTH: Option<usize>;
// Required methods
fn describe<Visitor>(visitor: &mut Visitor)
where Visitor: KeyVisitor;
fn as_ord_bytes(&self) -> Result<Cow<'_, [u8]>, Self::Error>;
}
Expand description
A trait that enables a type to convert itself into a memcmp
-compatible
sequence of bytes.
Required Associated Types§
Required Associated Constants§
Required Methods§
fn describe<Visitor>(visitor: &mut Visitor)where
Visitor: KeyVisitor,
fn describe<Visitor>(visitor: &mut Visitor)where Visitor: KeyVisitor,
Describes this type by invoking functions on visitor
describing the
key being encoded.
See the KeyVisitor
trait for more information.
KeyDescription::for_key()
/KeyDescription::for_encoding()
are
built-in functions
fn as_ord_bytes(&self) -> Result<Cow<'_, [u8]>, Self::Error>
fn as_ord_bytes(&self) -> Result<Cow<'_, [u8]>, Self::Error>
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.