strict-yaml-rust
A StrictYAML implementation for Rust obtained by savagely chopping off code from yaml-rust.
Now with built-in serde support as an optional feature! (@puetzp)
What is StrictYAML?
StrictYAML is a subset of the YAML format, removing troublesome parts of the specification:
- No typing. StrictYAML only knows Strings, Arrays and Dicts (Maps)
- No duplicate keys
- No tags
- No anchors or refs
- No "flow" style (embedded JSON)
In short, keeping only the parts of YAML that we all know and love.
For more details, see the original documentation and implementation:
Caveats
Missing from this implementation is a programmatic schema, which would enable document validation and typed value parsing. Seems that you'll still have to parse integers and dates from strings, or send a PR!
Quick Start
Add the following to the Cargo.toml of your project:
[]
= "0.1"
or
[]
= "https://github.com/fralalonde/strict-yaml-rust.git"
Use StrictYamlLoader to load the YAML documents, access it as Vec/HashMap and finally print it to stdout via StrictYamlEmitter:
use ;
Note that strict_yaml_rust::StrictYaml implements Index<&'a str> AND Index<usize>:
Index<usize>assumes the container is an ArrayIndex<&'a str>assumes the container is a string to value Map- otherwise,
Yaml::BadValueis returned
Features
- Pure Rust
- Ruby-like Array/Hash access API
- Low-level StrictYAML events emission
Specification Compliance
This implementation aims to provide StrictYAML parser fully compatible with the StrictYAML specification.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Fork & PR on Github.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.