babbel_cbor
Fast, binary-safe RFC 8949 CBOR (Concise Binary Object Representation) parser, serializer, and FormatEngine in pure Rust with zero external runtime dependencies.
Features
- Full RFC 8949 Specification Support: Encodes and decodes all major types:
- Major 0: Unsigned integers (
0up tou64::MAX) - Major 1: Negative integers (
-1down to-1 - u64::MAX) - Major 2: Byte strings (definite & indefinite-length chunks)
- Major 3: UTF-8 Text strings (definite & indefinite-length chunks)
- Major 4: Arrays (definite & indefinite-length)
- Major 5: Maps (definite & indefinite-length key-value pairs)
- Major 6: Semantic tags (unwrapping & payload preservation)
- Major 7: Simple values (
false,true,null,undefined) & IEEE 754 floats (half, single, double precision)
- Major 0: Unsigned integers (
- Universal AST: Maps 1:1 with Babbel's
Value. - Security & DoS Protection: Built-in maximum recursion depth (default 128) and payload size limit (default 64 MB).
- Embedded &
no_stdReady: Zero dynamic allocation requirements for streaming; works inallocenvironments. - OCP & DIP Architecture: Implements
FormatEngine, enabling instant integration intobabbel::FormatRegistryand cross-format conversion.
Usage
[]
= "0.2.1"
Parsing and Serializing
use ;
use ;
let data = Object;
// Encode to CBOR binary
let bytes = to_vec?;
// Decode back to universal Value AST
let decoded = from_bytes?;
assert_eq!;
// Use via FormatEngine trait
let engine = CborEngine;
let bytes2 = engine.serialize_to_vec?;
let decoded2 = engine.parse_bytes?;
assert_eq!;
# Ok::
Examples
Run any of the included examples with cargo:
# Basic parse, serialize, and AST exploration
# RFC 8949 indefinite-length containers and chunked streaming
# Babbel FormatEngine integration and trait usage