Expand description
A YAML 1.2 parser using a 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 ensuring about YAML spec but almost functions are well-implemented.
The buffer reader has also not been implemented, but sub-parsers can read the chunks.
WARNING: YAML 1.2 is compatible with JSON (JavaScript Object Notation) format, but not in the strict mode.
§Parser
Function parse
/parse_cyclic
is used to parse YAML string into
Node
data structure, which has a data holder Yaml
.
There also has a multiple-threaded 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.
§Anchor Parsing
parse
: The parser will replace the anchors during parsing.parse_cyclic
: Cyclic data means that a parent alias is inserted at the child node. Keep the alias to avoid having undefined anchors when parsing.
§No Standard Library
The std
feature is a default feature, use --no-default-features
to build
in the no-std mode.
§Serialization and Deserialization
Enable serde
feature to use serde
crate,
which provides a set of protocol traits to convert between custom Rust data.
Please be aware that the additional fields will be discarded 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 are still able to transform to YAML
data without serialization, according to built-in From
and Into
traits.
Re-exports§
pub use crate::dumper::dump;
pub use crate::parser::parse;
pub use crate::parser::parse_cyclic;
Modules§
- dumper
- Dumper components.
- parser
- Parser components, includes parser error.
- repr
- This module contains the representation holders, the underlay type of
Yaml
type. - serde
serde
- The implementation of serialization. The technique is come from
serde
.
Macros§
Structs§
- Ind
- Indicator of the node use to index the sequence position.
- Node
- Readonly node, including line number, column number, type assertion and
anchor. You can access
Yaml
type throughNode::yaml
method.
Enums§
Functions§
- indicated_
msg - Indicate the position of the documentation. This function will show the line number and column number of the position.
- indicated_
msg_ file - Same as
indicated_msg
, but join the path before message.
Type Aliases§
- Map
- The map data structure of YAML.
- NodeArc
- A node with
alloc::sync::Arc
holder. - NodeRc
- A node with
alloc::rc::Rc
holder. - Seq
- The sequence data structure of YAML.
- YamlArc
- A YAML data with
alloc::sync::Arc
holder. - YamlRc
- A YAML data with
alloc::rc::Rc
holder.