Crate saphyr

Source
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§

AnnotatedYamlIter
An iterator over a YamlData node.
MarkedYaml
A YAML node with Spans pointing to the start of the node.
MarkedYamlOwned
A YAML node with Spans pointing to the start of the node.
Marker
A location in a yaml document.
ScanError
An error that occurred while scanning.
Tag
A YAML tag.
YamlDecoder
A YamlLoader builder that allows you to supply your own encoding error trap.
YamlEmitter
The YAML serializer.
YamlIter
An iterator over a Yaml node.
YamlLoader
Main structure for parsing YAML.
YamlOwnedIter
An iterator over a YamlOwned node.

Enums§

Scalar
The resolved value of a scalar YAML node.
ScalarOwned
The resolved value of a scalar YAML node, freed from borrowing.
ScalarStyle
The style as which the scalar was written in the YAML document.
YAMLDecodingTrap
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.
YamlData
YAML data for nodes that will contain annotations.
YamlDataOwned
YAML data for nodes that will contain annotations.
YamlOwned
A YAML node is stored as this Yaml enumeration, which provides an easy way to access your YAML document.

Traits§

AnnotatedNode
A trait allowing for introspection in the hash types of the YamlData::Mapping variant.
AnnotatedNodeOwned
A trait allowing for introspection in the hash types of the YamlData::Mapping variant.
LoadableYamlNode
A trait providing methods used by the YamlLoader.

Type Aliases§

AnnotatedMapping
The type contained in the YamlData::Mapping variant. This corresponds to YAML mappings.
AnnotatedSequence
The type contained in the YamlData::Sequence variant. This corresponds to YAML sequences.
Mapping
The type contained in the Yaml::Mapping variant.
MappingOwned
The type contained in the YamlOwned::Mapping variant.
Sequence
The type contained in the Yaml::Sequence variant.
SequenceOwned
The type contained in the YamlOwned::Sequence variant.
YAMLDecodingTrapFn
The signature of the function to call when using YAMLDecodingTrap::Call.