1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! Canonical, order-preserving fixed-length byte encodings for plaintext
//! types.
//!
//! Each supported type implements [`ToOrderableBytes`], which maps a
//! value to a fixed-length byte array whose byte-wise lexicographic
//! order agrees with the type's natural total order, and whose byte
//! equality agrees with the type's value equality. The resulting bytes
//! are scheme-agnostic — they're intended for any comparison-as-bytes
//! scheme that wants to preserve plaintext order on ciphertexts (e.g.
//! `ore-rs` BlockORE, an OPE construction, an ordered hash).
//!
//! Encoders are gated behind per-type feature flags so callers only pay
//! for the dependencies they actually use.
extern crate quickcheck;
/// Maps a value to its canonical, order-preserving fixed-length byte
/// encoding.
///
/// Implementors guarantee, for any `a` and `b` of the implementing type:
///
/// - **Equality:** byte equality of the outputs agrees with the type's
/// value equality (`a.to_orderable_bytes() == b.to_orderable_bytes()`
/// iff `a == b`).
/// - **Order:** byte-wise lexicographic comparison of the outputs agrees
/// with the type's natural total order
/// (`a.to_orderable_bytes() <= b.to_orderable_bytes()` iff `a <= b`).
///
/// The encoded length is fixed per type and exposed via
/// [`ENCODED_LEN`](Self::ENCODED_LEN). Per-type modules also re-export
/// the same value as a free `pub const` for use in const contexts where
/// naming the impl would be unwieldy.