babbel
The master facade crate for the Babbel multi-format serialization and document processing ecosystem. It provides unified ergonomics, re-exports all domain engines (JSON, TOML, YAML, XML, Bencode, CSV, TSV, INI, JSON Lines), provides dynamic format resolution via FormatRegistry, and powers open-ended, $O(N)$ cross-format conversion pipelines.
Features
- Unified Prelude: Access all formats and text processing primitives with a single dependency.
- Polyglot Parsing: Parse JSON, TOML, YAML, XML, Bencode, CSV/TSV, and INI into idiomatic typed representations.
- Universal Cross-Conversion: Convert documents between 9 arbitrary formats without manual intermediate representations:
- JSON $\leftrightarrow$ TOML $\leftrightarrow$ YAML $\leftrightarrow$ XML $\leftrightarrow$ Bencode
- CSV / TSV $\leftrightarrow$ JSON $\leftrightarrow$ TOML $\leftrightarrow$ YAML
- INI / .env $\leftrightarrow$ JSON $\leftrightarrow$ TOML $\leftrightarrow$ YAML
- JSON Lines $\leftrightarrow$ JSON $\leftrightarrow$ TOML $\leftrightarrow$ CSV
- Engine-Driven Pipelines (
convert_format): Open-ended pipelines accepting anyFormatEngine(OCP & DIP). - Dynamic Format Discovery: Look up format engines dynamically by format ID, MIME type, or file extension via
FormatRegistry. - Zero-Allocation Embedded Module (
babbel::embedded):- Stack allocation:
StackBuffer<const N>,MemoryTracker,EmbeddedLimits,CompactError. - Zero-allocation destinations:
SliceDestinationandArrayVecDestination. - Zero-allocation streaming pull parsers:
JsonPullParser,TomlPullParser,XmlPullParser,CsvPullParser, andIniPullParser.
- Stack allocation:
- First-Class Text Processing:
- RFC 4180 CSV & TSV parsing/emission with automatic delimiter sniffing and scalar type inference.
- Section-based INI (
[section]), Java.properties, and.envparsing. - Line-delimited JSON (
.jsonl/.ndjson) streaming reader and writer. - Document frontmatter extraction (
split_frontmatterfor YAML---and TOML+++).
- Extensible Streaming I/O: Stream to and from files or memory buffers powered by
babbel_core. - Fine-Grained Feature Flags: Enable only the formats your application requires.
Installation
Add babbel to your Cargo.toml:
[]
= "0.3.0"
Or as a workspace path dependency:
[]
= { = "crates/babbel" }
Feature Flags
By default, all formats and the conversion pipeline are enabled (["std", "json", "toml", "yaml", "xml", "bencode", "msgpack", "cbor", "bson", "convert", "serde"]). To minimize binary size, enable only what you need:
| Feature | Description |
|---|---|
std (default) |
Enables standard library I/O and OS integration. |
alloc |
Enables heap allocation without full std (no_std environments). |
json (default) |
Re-exports babbel_json (babbel::json, JsonEngine, pull parser). |
toml (default) |
Re-exports babbel_toml (babbel::toml, TomlEngine, pull parser). |
yaml (default) |
Re-exports babbel_yaml (babbel::yaml, YamlEngine). |
xml (default) |
Re-exports babbel_xml (babbel::xml, XmlEngine, pull parser). |
bencode (default) |
Re-exports babbel_bencode (babbel::bencode, BencodeEngine). |
msgpack (default) |
Re-exports babbel_msgpack (babbel::msgpack, MsgPackEngine). |
cbor (default) |
Re-exports babbel_cbor (babbel::cbor, CborEngine). |
bson (default) |
Re-exports babbel_bson (babbel::bson, BsonEngine). |
convert (default) |
Enables the babbel::convert cross-format conversion pipeline across all 12 formats. |
serde (default) |
Enables universal serde serializing and deserializing for Value. |
Quickstart
1. Document Parsing & Navigation
use json;
use toml;
use yaml;
use xml;
use bencode;
use ;
2. Universal Cross-Format Conversions
use ;
use JsonEngine;
use TomlEngine;
use YamlEngine;
3. Dynamic Format Registry
use ;
4. Zero-Allocation Streaming Pull Parsers
use ;
Sub-Libraries
| Crate | Link | Description |
|---|---|---|
babbel_core |
crates/babbel_core |
Core I/O traits, FormatEngine, universal Value AST, RFC 4180 CSV/TSV, INI/.env, frontmatter, BOM detection, and embedded primitives. |
babbel_json |
crates/json |
RFC 6901 JSON Pointer, RFC 7396 Merge Patch, JSON Lines (.jsonl/.ndjson) streaming, and zero-allocation JsonPullParser. |
babbel_toml |
crates/toml |
Strict TOML v1.1.0 parser/emitter with micro-allocations, typed RFC 3339 datetimes, and TomlPullParser. |
babbel_yaml |
crates/yaml |
YAML 1.2 specification compliance, anchors, aliases, and custom tags. |
babbel_xml |
crates/xml |
XML DOM, C14N Canonical XML, DTD validation, XSD schema, XPath 1.0, and XmlPullParser. |
babbel_bencode |
crates/bencode |
Zero-copy borrowed parsing and streaming for BitTorrent Bencode. |
babbel_msgpack |
crates/msgpack |
Fast, binary-safe MessagePack parser, serializer, and FormatEngine. |
babbel_cbor |
crates/cbor |
RFC 8949 CBOR parser, serializer, indefinite streaming, and FormatEngine. |
babbel_bson |
crates/bson |
BSON (Binary JSON) parser, serializer, document model, and FormatEngine. |
Examples
Run any of the root examples using cargo:
# Full 8-format conversion pipeline (JSON -> TOML -> YAML -> XML -> Bencode -> MsgPack -> CBOR -> BSON)
# Binary formats size and byte structure comparison (JSON vs Bencode vs BSON vs CBOR vs MsgPack)
Documentation
See the Documentation Hub for full workspace guides:
- Architecture Guide
- SOLID Architecture Whitepaper
- Format Engine Plugin Guide
- Embedded Systems Guide
- Conversion Matrix
- Memory & Benchmarks
- Migration Guide & Changelog
License
Licensed under the MIT License.