Skip to main content

Crate babbel_kdl

Crate babbel_kdl 

Source
Expand description

§Babbel KDL

Fast, pure-Rust parser, serializer, and [FormatEngine] implementation for KDL (KDL Document Language), a human-friendly configuration and document language.

§Features

  • Full KDL Syntax: Nodes, positional arguments, named properties (key=val), and nested children blocks ({ ... }).
  • Comments: Single-line (//), nested multi-line block (/* /* */ */), and node/entry slashdash comments (/-).
  • Rich Types: Raw strings (r#"..."#), unicode escape sequences (\u{...}), number bases (hex 0x, octal 0o, bin 0b, float, exponents, underscores), booleans (true/false), and null.
  • Zero Dependencies: Pure Rust with optional no_std + alloc support.
  • Unified Architecture: Integrates into Babbel’s universal Value AST and cross-format conversion matrix.

§Quickstart

use babbel_kdl::{from_str, to_string_pretty};

let kdl_source = r#"
package {
    name "babbel"
    version "0.2.1"
    features "kdl" "ron"
}
"#;

let value = from_str(kdl_source).expect("parse failed");
assert!(value.get("package").is_some());

let pretty_kdl = to_string_pretty(&value, 2).expect("serialize failed");
println!("{}", pretty_kdl);

Re-exports§

pub use ast::KdlDocument;
pub use ast::KdlEntry;
pub use ast::KdlNode;
pub use ast::KdlValue;
pub use engine::KdlEngine;
pub use error::KdlError;
pub use parser::parse_document;
pub use serializer::to_string;
pub use serializer::to_string_pretty;

Modules§

ast
KDL Document Abstract Syntax Tree and conversion to Babbel Value.
engine
KDL Format Engine implementation adhering to OCP and DIP.
error
Error types for the KDL parser and serializer.
parser
KDL recursive-descent parser supporting full KDL syntax.
serializer
KDL serializer supporting compact and pretty-printed formatting.

Enums§

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

Functions§

from_bytes
Deserialize a universal Babbel Value from UTF-8 KDL bytes.
from_slice
Deserialize a universal Babbel Value from UTF-8 KDL bytes.
from_str
Deserialize a universal Babbel Value from a KDL string.
to_vec
Serialize a universal Babbel Value to a KDL byte vector.