Expand description
High-level bindings for the LibYAML library.
Reading YAML
To read a YAML stream, use Parser
. This example counts the number of
alias events in a stream.
let alias_count = Parser::new(reader)?.into_iter().filter(|e| {
if let Ok(Event::Alias { .. }) = e { true } else { false }
}).count();
Writing YAML
To write a YAML stream, use Emitter
. This example writes a stream with
a single document consisting of a single scalar.
let mut emitter = Emitter::new(writer)?;
emitter.emit(Event::StreamStart { encoding: None })?;
emitter.emit(Event::DocumentStart { implicit: true })?;
emitter.emit(Event::Scalar {
anchor: None,
tag: Some(tag::INT.to_string()),
value: "42".to_string(),
plain_implicit: false,
quoted_implicit: false,
style: None,
})?;
emitter.emit(Event::DocumentEnd { implicit: true })?;
emitter.emit(Event::StreamEnd)?;
Modules
Tags for YAML language-independent types.
Structs
Emitter.
Builder for emitters.
Error returned from Event
methods.
Parser.
Builder for parsers.
Iterator adapter for Parser
.
Document tag directive.
Document version directive.