KDL Schema types and parsing.
rust
use kdl_schema::*;
let schema = Schema {
document: Document {
info: Info {
title: vec![TextValue {
text: "Sample Schema".to_string(),
lang: Some("en".to_string()),
}],
..Info::default()
},
nodes: vec![Node {
name: Some("name".to_string()),
values: vec![Value {
validations: vec![Validation::Type("string".to_string())],
..Value::default()
}],
..Node::default()
}]
}
};
println!("{:?}", schema);
```rust
let schema_kdl = r#"
document { info { title "Sample Schema" lang="en" description "An example schema" lang="en" author "boringcactus" } node "name" { value { type "string" } } node "age" { value { type "number" } } } "#; let matchingdocument = r#" name "Joe" age 69 "#; let schema = kdlschema::Schema::parse(schemakdl).unwrap(); assert_eq!(schema.document.info.title[0].text, "Sample Schema"); } ```
rust
assert_eq!(kdl_schema::SCHEMA_SCHEMA.document.info.title[0].text, "KDL Schema");
parse-knuffel
- expose Schema::parse
, powered by the knuffel
craterequired false
in a prop
works properly