Trait LmdbOrdKey

Source
pub unsafe trait LmdbOrdKey: FromLmdbBytes + Ord {
    // Provided methods
    fn ordered_by_bytes() -> bool { ... }
    fn ordered_as_integer() -> bool { ... }
}
Expand description

Trait describing a value which can be used as an LMDB key by having LMDB call into the value’s Ord implementation.

§Unsafety

Behaviour is undefined if the FromLmdbBytes or Ord implementations panic.

Provided Methods§

Source

fn ordered_by_bytes() -> bool

Returns whether the default LMDB byte-by-byte comparison is correct for valid values of this type.

Generally, one should not specifically use DatabaseOptions::sort_values_as and so forth for types where this is the case. This function exists to support generic code wishing to avoid the conversion overhead when the types happen to already be byte-comparable.

Note that if this returns true, that does not mean that byte comparison is exactly equivalent to Ord-based comparison. For example, invalid str instances sort before valid ones and are equal to each other, but byte comparison will intermingle them. Because of this, DatabaseOptions::sort_values_as and similar do not make decisions based on this value; it is the client code’s responsibility to use this if so desired.

§Example
assert!(<u8 as LmdbOrdKey>::ordered_by_bytes());
assert!(!<i8 as LmdbOrdKey>::ordered_by_bytes());
assert!(<str as LmdbOrdKey>::ordered_by_bytes());
assert!(<[u8] as LmdbOrdKey>::ordered_by_bytes());
assert!(!<[i8] as LmdbOrdKey>::ordered_by_bytes());
Source

fn ordered_as_integer() -> bool

Returns whether LMDB will correctly handle this value with the INTEGERKEY or INTEGERDUP flags.

There’s generally no reason to use sort_keys_as and so forth with values where this is true instead of using the appropriate flags. This function exists to support generic code which wants to make such decisions automatically.

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.

Implementations on Foreign Types§

Source§

impl LmdbOrdKey for i8

Source§

impl LmdbOrdKey for str

Source§

impl LmdbOrdKey for u8

Source§

impl LmdbOrdKey for CStr

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 0]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 1]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 2]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 3]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 4]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 5]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 6]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 7]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 8]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 9]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 10]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 11]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 12]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 13]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 14]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 15]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 16]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 17]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 18]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 19]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 20]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 21]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 22]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 23]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 24]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 25]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 26]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 27]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 28]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 29]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 30]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 31]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 32]

Source§

impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V]

Implementors§