char_traits.rs |
Holds functions to determine if a character belongs to a specific character set. |
3610 |
debug.rs |
Debugging helpers.
Debugging is governed by two conditions:
1. The build mode. Debugging code is not emitted in release builds and thus not available.
2. The `YAMLALL_DEBUG` environment variable. If built in debug mode, the program must be fed
the `YAMLALL_DEBUG` variable in its environment. While debugging code is present in debug
build, debug helpers will only trigger if that variable is set when running the program. |
1394 |
emitter.rs |
YAML serialization helpers. |
13682 |
lib.rs |
YAML 1.2 implementation in pure Rust.
# Usage
This crate is [on github](https://github.com/Ethiraric/yaml-rust2) and can be used by adding
`yaml-rust2` to the dependencies in your project's `Cargo.toml`.
```sh
cargo add yaml-rust2
```
# Examples
Parse a string into `Vec<Yaml>` and then serialize it as a YAML string.
```
use yaml_rust2::{YamlLoader, YamlEmitter};
let docs = YamlLoader::load_from_str("[1, 2, 3]").unwrap();
let doc = &docs[0]; // select the first YAML document
assert_eq!(doc[0].as_i64().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.65.0`.
#### `debug_prints`
Enables the `debug` module and usage of debug prints in the scanner and the parser. Do not
enable if you are consuming the crate rather than working on it as this can significantly
decrease performance.
The MSRV for this feature is `1.70.0`. |
1842 |
parser.rs |
Home to the YAML Parser.
The parser takes input from the [`crate::scanner::Scanner`], performs final checks for YAML
compliance, and emits a stream of tokens that can be used by the [`crate::YamlLoader`] to
construct the [`crate::Yaml`] object. |
40310 |
scanner.rs |
Home to the YAML Scanner.
The scanner is the lowest-level parsing utility. It is the lexer / tokenizer, reading input a
character at a time and emitting tokens that can later be interpreted by the [`crate::parser`]
to check for more context and validity.
Due to the grammar of YAML, the scanner has to have some context and is not error-free. |
89010 |
yaml.rs |
YAML objects manipulation utilities. |
34022 |