Expand description

A YAML 1.2 parser using greedy parsing algorithm with PEG atoms.

The major purpose of this crate is to let the user build their own YAML reader / builder / validator.

This parser is not ensure about YAML spec but almost functions are well-implemented.

The buffer reader has also not implemented, but the chunks can be read by sub-parsers.

WARN: YAML 1.2 is compatible with JSON (JavaScript Object Notation) format, but not in strict mode.

Parser

Function parse is used to parse YAML string into Node data structure, which has a data holder Yaml. There also has multiple thread version corresponding to NodeRc / NodeArc and YamlRc / YamlArc. To get back as string, please use dump function.

There are also have some macros for building Node structure from Rust data. Especially node! macro, almost data can be built by the macro literally.

If you went to rise your own error message, indicated_msg might be a good choice.

Anchors

The anchor system Anchor is implemented by using alloc::rc::Rc and alloc::sync::Arc as inner handler. Additionally, anchors! macro can used to create anchor visitor by yourself.

Serialization and Deserialization

Enable serde / serde-std feature to use serde crate. The crate provides a set of protocol traits to convert between custom Rust data. Please be aware that the additional fields will be discard when convert to a fix-sized structure. For example, the structure fields can be turned into map keys as well.

On the other hand, the primitive types still able to transform to YAML data without serialization, according to From and Into traits. See crate::serde module for more information.

Re-exports

pub use crate::dumper::dump;
pub use crate::parser::parse;

Modules

Dumper components.

Parser components, includes parser error.

This module contains representation holder, the reference counter type.

serdeserde

The implementation of serialization. The technique is come from serde.

Macros

Create a custom anchor visitor.

Create Node items literally.

Structs

Anchor visitor is made by a hash map that you can get the node reference inside.

Indicator of the node use to index the sequence position.

The error of using an invalid anchor.

Readonly node, including line number, column number, type assertion and anchor. You can access Yaml type through Node::yaml method.

Enums

YAML data types, but it is recommended to use Node for shorten code.

Functions

Indicate the position of the documentation. This function will show the line number and column number of the position.

Same as indicated_msg, but join the path before message.

Type Definitions

An anchor visitor with alloc::sync::Arc holder.

An anchor visitor with alloc::rc::Rc holder.

The map data structure of YAML.

A node with alloc::sync::Arc holder.

A node with alloc::rc::Rc holder.

The sequence data structure of YAML.

A YAML data with alloc::sync::Arc holder.

A YAML data with alloc::rc::Rc holder.