#[non_exhaustive]pub enum KeyOrder {
Bytewise,
LengthFirst,
}Expand description
The map key ordering used by deterministic encoding.
RFC 8949 defines two deterministic key orderings. They agree whenever
all keys encode to the same length, but differ otherwise: for example,
100 (0x1864) sorts after -1 (0x20) bytewise, but before it
length-first.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Bytewise
Bytewise lexicographic order of the keys’ deterministic encodings.
This is the order required by the core deterministic encoding requirements (RFC 8949 §4.2.1) and is the recommended choice for new protocols; COSE (RFC 9052) and friends use it.
LengthFirst
Length-first order: keys with shorter encodings sort earlier, and keys of equal length sort bytewise.
This is the “Canonical CBOR” ordering of RFC 7049 §3.9, kept in
RFC 8949 §4.2.3 for backwards compatibility. Use it to interoperate
with protocols and implementations built on the older rule (for
example, ciborium’s canonical module).