Development has moved to yaml-rust2
IMPORTANT The enhancements from this fork have been merged into yaml-rust2, the de-facto Rust YAML implementation.
All future development has moved to yaml-rust2
.
Users are advised to upgrade to yaml-rust2
.
Upgrading to yaml-rust2
You can use yaml-rust2
as a drop-in replacement for yaml-rust
by setting the package
option
to yaml-rust2
in your project's Cargo.toml
.
[]
= { = "0.7", = "yaml-rust2" }
The original README from yaml-rust-davvid follows below:
yaml-rust
The missing YAML 1.2 implementation for Rust.
yaml-rust
is a pure Rust YAML 1.2 implementation,
which enjoys the memory safety
property and other benefits from the Rust language.
The parser is heavily influenced by libyaml
and yaml-cpp
.
Quick Start
Add the following to the Cargo.toml of your project:
[]
= { = "0.6", = "yaml-rust-davvid" }
Use yaml::YamlLoader
to load the YAML documents and access it
as Vec/HashMap:
use ;
Note that yaml_rust::Yaml
implements Index<&'a str>
& Index<usize>
:
Index<usize>
assumes the container is an ArrayIndex<&'a str>
assumes the container is a string to value Map- otherwise,
Yaml::BadValue
is returned
If your document does not conform to this convention (e.g. map with
complex type key), you can use the Yaml::as_XXX
family API to access your
documents.
Features
- Pure Rust
- Ruby-like Array/Hash access API
- Low-level YAML events emission
Specification Compliance
This implementation aims to provide YAML parser fully compatible with the YAML 1.2 specification. The parser can correctly parse almost all examples in the specification, except for the following known bugs:
- Empty plain scalar in certain contexts
However, the widely used library libyaml
also fails to parse these examples,
so it may not be a huge problem for most users.
Security
This library does not try to interpret any type specifiers in a YAML document, so there is no risk of, say, instantiating a socket with fields and communicating with the outside world just by parsing a YAML document.
Goals
- Encoder
- Tag directive
- Alias while deserialization
Minimum Rust version policy
This crate's minimum supported rustc
version is 1.31 (released with Rust 2018, after v0.4.3), as this is the currently known minimum version for regex
as well.
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.
Acknowlegements
yaml-rust-davvid
is a fork of the original, and now unmaintained
yaml-rust parser by chyh1990.