Crates.io | kdl-schema |
lib.rs | kdl-schema |
version | 0.1.0 |
source | src |
created_at | 2022-03-28 06:52:30.684238 |
updated_at | 2022-03-28 06:52:30.684238 |
description | schema types & parsing for KDL |
homepage | |
repository | https://code.boringcactus.com/kdl-schema/ |
max_upload_size | |
id | 557650 |
size | 77,650 |
KDL Schema types and parsing.
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);
#[cfg(feature = "parse-knuffel")] {
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 _matching_document = r#"
name "Joe"
age 69
"#;
let schema = kdl_schema::Schema::parse(schema_kdl).unwrap();
assert_eq!(schema.document.info.title[0].text, "Sample Schema");
}
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