Crate entidb_codec

Crate entidb_codec 

Source
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§

CanonicalDecoder
A canonical CBOR decoder.
CanonicalEncoder
A canonical CBOR encoder.

Enums§

CodecError
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§

CodecResult
Result type for codec operations.