Skip to main content

Crate codec_cbor

Crate codec_cbor 

Source
Expand description

Deterministic generic CBOR and a DAG-CBOR subset with content-ID helpers.

Both profiles use length-first key ordering (RFC 8949 §4.2.3) and reject non-canonical integers, indefinite-length items, floats, tags, out-of-order map keys, and trailing bytes, so a given value has exactly one accepted encoding. DAG-CBOR supports text map keys and signed 64-bit integers. Generic CBOR also supports integer map keys and the full unsigned 64-bit range. Input-size and nesting limits bound parser work; declared container lengths are checked against remaining input before allocating their contents.

Structs§

DagCborCidVerification
Validated CID comparison with canonical, input-independent diagnostics.
DagCborMultihash
SHA-256 multihash for a DAG-CBOR block.
DeterministicCborMapEntry
Entry in a deterministic-CBOR map.
DeterministicCborNegativeInteger
Validated negative integer in the deterministic-CBOR supported range.
ParsedCid
Validated CID, independent of the upstream CID type.

Enums§

CborError
Error returned when decoding fails to conform to the DAG-CBOR profile.
CborValue
A decoded DAG-CBOR value.
CidVerificationStatus
Outcome of comparing a canonical DAG-CBOR block with a CID string.
DeterministicCborError
Error returned by deterministic generic-CBOR encoding and decoding.
DeterministicCborInteger
Integer domain supported by the deterministic generic-CBOR profile.
DeterministicCborMapKey
Map key domain supported by deterministic generic CBOR.
DeterministicCborProfileError
Errors raised by deterministic-CBOR profile construction and validation.
DeterministicCborValue
Value domain supported by deterministic generic CBOR.

Constants§

DAG_CBOR_CODEC
dag-cbor multicodec code (IPLD)
DETERMINISTIC_CBOR_NEGATIVE_MAX
Largest negative integer supported by the deterministic generic profile.
DETERMINISTIC_CBOR_NEGATIVE_MIN
Smallest negative integer supported by the deterministic generic profile.
MAX_CID_STRING_LEN
Maximum CID string size accepted before multibase decoding.
MAX_DAG_CBOR_CONTAINER_ENTRIES
Maximum entries in one DAG-CBOR array or map.
MAX_DAG_CBOR_INPUT_LEN
Maximum encoded DAG-CBOR byte length accepted by encode and decode.
MAX_DAG_CBOR_NODES
Maximum semantic nodes accepted by the DAG-CBOR profile.
MAX_DETERMINISTIC_CBOR_AGGREGATE_BYTE_STRING_BYTES
Maximum aggregate bytes across all byte-string values.
MAX_DETERMINISTIC_CBOR_AGGREGATE_TEXT_BYTES
Maximum aggregate UTF-8 bytes across all text values and text map keys.
MAX_DETERMINISTIC_CBOR_CONTAINER_ENTRIES
Maximum entries in a single deterministic-CBOR array or map.
MAX_DETERMINISTIC_CBOR_INPUT_LEN
Maximum encoded deterministic-CBOR byte length accepted at public decode boundaries.
MAX_DETERMINISTIC_CBOR_NESTING_DEPTH
Maximum recursive array/map nesting depth for deterministic generic CBOR.
MAX_DETERMINISTIC_CBOR_NODES
Maximum semantic nodes in a deterministic-CBOR value tree.
MAX_DETERMINISTIC_CBOR_OUTPUT_LEN
Maximum deterministic-CBOR byte length the encoder may produce.
MAX_NESTING_DEPTH
Maximum array/map nesting depth accepted by DAG-CBOR encode and decode.

Functions§

compute_cid_dag_cbor
Computes the CIDv1 (dag-cbor, sha2-256) of bytes in canonical base32-lower string form.
dag_cbor_multihash
Returns a sha2-256 multihash of bytes for use in a CID.
decode_dag_cbor
Decode canonical DAG-CBOR bytes into a CborValue.
decode_deterministic_cbor
Decode deterministic generic-CBOR bytes into the supported semantic value.
encode_dag_cbor
Encode a value using canonical DAG-CBOR.
encode_deterministic_cbor
Encode a value using the deterministic generic-CBOR profile.
is_valid_cid_string
Returns whether s parses as a valid CID string.
sha2_256_content_hash
Returns the raw sha2-256 digest of bytes.
try_parse_cid
Parses s as a CID, returning None if it is not a valid CID string.
verify_dag_cbor_cid
Validate one canonical DAG-CBOR block and compare its CID text.

Type Aliases§

ContentHash
Hash output for sha2-256