Skip to main content

Crate babbel_cbor

Crate babbel_cbor 

Source
Expand description

§Babbel CBOR

Fast, binary-safe, zero-copy RFC 8949 CBOR (Concise Binary Object Representation) parser, serializer, and DOM engine in pure Rust. Adheres strictly to the IETF CBOR standard and Babbel’s SOLID architecture.

CBOR maps with 100% fidelity to Babbel’s universal Value AST:

  • Null / Undefined -> Value::Null
  • Boolean -> Value::Bool
  • Unsigned & Negative integers -> Value::Integer(i128)
  • 16-bit, 32-bit & 64-bit IEEE floats -> Value::Float(f64)
  • UTF-8 Strings (definite & indefinite) -> Value::String(String)
  • Byte arrays (definite & indefinite) -> Value::Bytes(Vec<u8>)
  • Arrays (definite & indefinite) -> Value::Array(Vec<Value>)
  • Maps (definite & indefinite) -> Value::Object(Vec<(String, Value)>)

§Quickstart

use babbel_cbor::{from_bytes, to_vec, CborEngine};
use babbel_core::Value;

let original = Value::Object(vec![
    ("standard".into(), Value::String("RFC 8949".into())),
    ("compact".into(), Value::Bool(true)),
]);

let encoded = to_vec(&original).unwrap();
let decoded = from_bytes(&encoded).unwrap();
assert_eq!(original, decoded);

Re-exports§

pub use edn::from_edn;
pub use edn::to_edn;
pub use engine::CborEngine;
pub use error::CborError;
pub use parser::Decoder;
pub use parser::DecoderConfig;
pub use parser::from_bytes;
pub use parser::from_bytes_seq;
pub use pull::CborPullEvent;
pub use pull::CborPullParser;
pub use serializer::EncoderConfig;
pub use serializer::serialize_to_dest;
pub use serializer::serialize_to_dest_canonical;
pub use serializer::to_vec;
pub use serializer::to_vec_canonical;
pub use serializer::to_vec_seq;
pub use constants::*;

Modules§

constants
CBOR (RFC 8949) binary format markers, masks, and constants.
edn
RFC 8949 Section 8 Extended Diagnostic Notation (EDN) for CBOR.
engine
CBOR Format Engine adhering to OCP and DIP.
error
Error types for CBOR (RFC 8949) encoding and decoding.
parser
High-performance CBOR (RFC 8949) decoder into universal Value AST.
pull
Streaming pull parser for CBOR (RFC 8949) payloads operating in O(1) memory.
serializer
High-performance CBOR (RFC 8949) serializer for universal Value AST.

Enums§

Value
Universal hierarchical data value across XML, JSON, YAML, and Bencode representations.

Functions§

from_slice
Convenience alias parsing CBOR from a byte slice into Value.