[−][src]Crate libyaml
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
tag | Tags for YAML language-independent types. |
Structs
Emitter | Emitter. |
EmitterBuilder | Builder for emitters. |
EventError | Error returned from |
Parser | Parser. |
ParserBuilder | Builder for parsers. |
ParserIter | Iterator adapter for |
TagDirective | Document tag directive. |
VersionDirective | Document version directive. |
Enums
EmitterError | Error returned from |
Encoding | Stream encoding. |
Event | Emitter or parser event. |
LineBreak | Line break encoding. |
MappingStyle | Mapping style. |
ParserError | Error returned from |
ScalarStyle | Scalar style. |
SequenceStyle | Sequence style. |
Functions
lib_version | Return LibYAML version as a |
lib_version_string | Return LibYAML version as a string. |