Trait lmdb_zero::traits::LmdbOrdKey
[−]
[src]
pub unsafe trait LmdbOrdKey: FromLmdbBytes + Ord { fn ordered_by_bytes() -> bool { ... } fn ordered_as_integer() -> bool { ... } }
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
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());
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.
Implementors
impl LmdbOrdKey for u8
impl LmdbOrdKey for i8
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 0]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 1]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 2]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 3]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 4]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 5]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 6]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 7]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 8]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 9]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 10]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 11]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 12]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 13]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 14]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 15]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 16]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 17]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 18]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 19]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 20]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 21]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 22]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 23]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 24]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 25]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 26]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 27]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 28]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 29]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 30]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 31]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V; 32]
impl<V: LmdbOrdKey + LmdbRaw> LmdbOrdKey for [V]
impl LmdbOrdKey for CStr
impl LmdbOrdKey for str
impl<T: LmdbRawIfUnaligned + LmdbOrdKeyIfUnaligned> LmdbOrdKey for Unaligned<T>