yaml_rust2/
lib.rs

1// Copyright 2015, Yuheng Chen.
2// Copyright 2023, Ethiraric.
3// See the LICENSE file at the top-level directory of this distribution.
4
5//! YAML 1.2 implementation in pure Rust.
6//!
7//! # Usage
8//!
9//! This crate is [on github](https://github.com/Ethiraric/yaml-rust2) and can be used by adding
10//! `yaml-rust2` to the dependencies in your project's `Cargo.toml`.
11//!
12//! ```sh
13//! cargo add yaml-rust2
14//! ```
15//!
16//! # Examples
17//! Parse a string into `Vec<Yaml>` and then serialize it as a YAML string.
18//!
19//! ```
20//! use yaml_rust2::{YamlLoader, YamlEmitter};
21//!
22//! let docs = YamlLoader::load_from_str("[1, 2, 3]").unwrap();
23//! let doc = &docs[0]; // select the first YAML document
24//! assert_eq!(doc[0].as_i64().unwrap(), 1); // access elements by index
25//!
26//! let mut out_str = String::new();
27//! let mut emitter = YamlEmitter::new(&mut out_str);
28//! emitter.dump(doc).unwrap(); // dump the YAML object to a String
29//!
30//! ```
31//!
32//! # Features
33//! **Note:** With all features disabled, this crate's MSRV is `1.65.0`.
34//!
35//! #### `encoding` (_enabled by default_)
36//! Enables encoding-aware decoding of Yaml documents.
37//!
38//! The MSRV for this feature is `1.65.0`.
39//!
40//! #### `debug_prints`
41//! Enables the `debug` module and usage of debug prints in the scanner and the parser. Do not
42//! enable if you are consuming the crate rather than working on it as this can significantly
43//! decrease performance.
44//!
45//! The MSRV for this feature is `1.70.0`.
46
47#![warn(missing_docs, clippy::pedantic)]
48
49extern crate hashlink;
50
51pub(crate) mod char_traits;
52#[macro_use]
53pub(crate) mod debug;
54pub mod emitter;
55pub mod parser;
56pub mod scanner;
57pub mod yaml;
58
59// reexport key APIs
60pub use crate::emitter::{EmitError, YamlEmitter};
61pub use crate::parser::Event;
62pub use crate::scanner::ScanError;
63pub use crate::yaml::{Yaml, YamlLoader};