Expand description
§EntiDB Codec
Canonical CBOR encoding/decoding for EntiDB.
This crate provides deterministic CBOR encoding that ensures:
- Identical inputs produce identical bytes
- Cross-platform consistency
- Stable hashing
§Canonical CBOR Rules
- Maps are sorted by key (bytewise comparison of encoded keys)
- Integers use shortest encoding
- No floats unless explicitly allowed
- Strings must be UTF-8
- No indefinite-length items
- No NaN values
§Usage
use entidb_codec::{to_canonical_cbor, from_cbor, Value};
// Encode a value
let value = Value::Integer(42);
let bytes = to_canonical_cbor(&value).unwrap();
// Decode back
let decoded: Value = from_cbor(&bytes).unwrap();
assert_eq!(value, decoded);Structs§
- Canonical
Decoder - A canonical CBOR decoder.
- Canonical
Encoder - A canonical CBOR encoder.
Enums§
- Codec
Error - Errors that can occur during encoding or decoding.
- Value
- A dynamic CBOR value.
Traits§
- Decode
- Trait for types that can be decoded from CBOR.
- Encode
- Trait for types that can be encoded to canonical CBOR.
Functions§
- from_
cbor - Decode a value from CBOR bytes.
- to_
canonical_ cbor - Encode a value to canonical CBOR bytes.
Type Aliases§
- Codec
Result - Result type for codec operations.