Skip to main content

Invariant

Trait Invariant 

Source
pub unsafe trait Invariant:
    Debug
    + Default
    + Hash
    + Eq
    + Ord
    + Send
    + Sync
    + 'static {
    type Error: Error;
    type Terminate: Terminate;

    // Required method
    fn validate(key: &[u8]) -> Result<(), Self::Error>;
}
Expand description

An invariant of [u8] that is sufficient to guarantee the prefix property (no key is a prefix of another key).

§Safety

Caller must ensure that if validate returns Ok(()), then key satisfies the prefix property.

Required Associated Types§

Source

type Error: Error

Validation error.

Source

type Terminate: Terminate

Implementation detail: some invariants append a logical terminator byte to the end of each key.

Required Methods§

Source

fn validate(key: &[u8]) -> Result<(), Self::Error>

Returns Ok(()) if and only if key satisfies this invariant.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl Invariant for NonNull

Source§

type Error = NonNullError

Source§

type Terminate = bool

Source§

impl<const TERMINATOR: u8> Invariant for Terminated<TERMINATOR>

Source§

type Error = TerminatedError

Source§

type Terminate = ()