Expand description
§xcdn
xcdn is a zero-copy, streaming-capable parser/serializer for xCDN — eXtensible Cognitive Data Notation.
The crate exposes three public layers:
lexertokenizes an xCDN document while tracking line/column.parserproduces a typed AST (ast::Document) including optional prolog directives.serpretty/compact serialization with strong typing (Decimal, UUID, DateTime, Duration, Bytes).
§Quick Start
use xcdn::{parse_str, ser::to_string_pretty, ast::Value};
let input = r#"
$schema: "https://gslf.github.io/xCDN/schemas/v1/meta.xcdn",
server_config: {
host: "localhost",
ports: [8080, 9090,],
timeout: r"PT30S",
max_cost: d"19.99",
admin: #user { id: u"550e8400-e29b-41d4-a716-446655440000", role: "superuser" },
icon: @mime("image/png") b"aGVsbG8=",
}"#;
let doc = parse_str(input).expect("valid xCDN");
assert!(doc.values.len() >= 1);
// Serialize it back
let text = to_string_pretty(&doc).unwrap();
println!("{}", text);§Design notes
- This implementation follows the public xCDN grammar and documentation.
- It supports: comments, unquoted keys, trailing commas, multi-line strings (
"""..."""), native types (Decimal, UUID, DateTime, Duration, Bytes),#tags, and@annotations. - We do not preserve comments/insignificant whitespace on serialization.
See the project repository for the xCDN specification and examples.
§Crate layout
ast— core data structureserror— structured error diagnostics with spanslexer— the tokenizerparser— recursive-descent parserser— serializer
§Optional (via serde feature)
The Value implements serde::Serialize / serde::Deserialize when the
serde feature is enabled, enabling easy bridging to your data types.
Re-exports§
pub use parser::parse_str;pub use parser::parse_reader;