Expand description
YAML 1.2 implementation in pure Rust.
§Usage
This crate is on github and can be used by adding
saphyr
to the dependencies in your project’s Cargo.toml
:
cargo add saphyr
§Examples
Parse a string into Vec<Yaml>
and then serialize it as a YAML string.
use saphyr::{LoadableYamlNode, Yaml, YamlEmitter};
let docs = Yaml::load_from_str("[1, 2, 3]").unwrap();
let doc = &docs[0]; // select the first YAML document
assert_eq!(doc[0].as_integer().unwrap(), 1); // access elements by index
let mut out_str = String::new();
let mut emitter = YamlEmitter::new(&mut out_str);
emitter.dump(doc).unwrap(); // dump the YAML object to a String
§Features
Note: With all features disabled, this crate’s MSRV is 1.65.0
.
§encoding
(enabled by default)
Enables encoding-aware decoding of Yaml documents.
The MSRV for this feature is 1.70.0
.
Structs§
- Annotated
Yaml Iter - An iterator over a
YamlData
node. - Marked
Yaml - A YAML node with
Span
s pointing to the start of the node. - Marked
Yaml Owned - A YAML node with
Span
s pointing to the start of the node. - Marker
- A location in a yaml document.
- Scan
Error - An error that occurred while scanning.
- Tag
- A YAML tag.
- Yaml
Decoder - A
YamlLoader
builder that allows you to supply your own encoding error trap. - Yaml
Emitter - The YAML serializer.
- Yaml
Iter - An iterator over a
Yaml
node. - Yaml
Loader - Main structure for parsing YAML.
- Yaml
Owned Iter - An iterator over a
YamlOwned
node.
Enums§
- Scalar
- The resolved value of a scalar YAML node.
- Scalar
Owned - The resolved value of a scalar YAML node, freed from borrowing.
- Scalar
Style - The style as which the scalar was written in the YAML document.
- YAML
Decoding Trap - The behavior
YamlDecoder
must have when an decoding error occurs. - Yaml
- A YAML node is stored as this
Yaml
enumeration, which provides an easy way to access your YAML document. - Yaml
Data - YAML data for nodes that will contain annotations.
- Yaml
Data Owned - YAML data for nodes that will contain annotations.
- Yaml
Owned - A YAML node is stored as this
Yaml
enumeration, which provides an easy way to access your YAML document.
Traits§
- Annotated
Node - A trait allowing for introspection in the hash types of the
YamlData::Mapping
variant. - Annotated
Node Owned - A trait allowing for introspection in the hash types of the
YamlData::Mapping
variant. - Loadable
Yaml Node - A trait providing methods used by the
YamlLoader
.
Type Aliases§
- Annotated
Mapping - The type contained in the
YamlData::Mapping
variant. This corresponds to YAML mappings. - Annotated
Sequence - The type contained in the
YamlData::Sequence
variant. This corresponds to YAML sequences. - Mapping
- The type contained in the
Yaml::Mapping
variant. - Mapping
Owned - The type contained in the
YamlOwned::Mapping
variant. - Sequence
- The type contained in the
Yaml::Sequence
variant. - Sequence
Owned - The type contained in the
YamlOwned::Sequence
variant. - YAML
Decoding Trap Fn - The signature of the function to call when using
YAMLDecodingTrap::Call
.