2024-02-08 06:12:14 +00:00
|
|
|
// Copyright 2015, Yuheng Chen.
|
|
|
|
// Copyright 2023, Ethiraric.
|
|
|
|
// See the LICENSE file at the top-level directory of this distribution.
|
2015-05-31 09:59:43 +00:00
|
|
|
|
|
|
|
//! YAML 1.2 implementation in pure Rust.
|
|
|
|
//!
|
|
|
|
//! # Usage
|
|
|
|
//!
|
2024-02-08 06:12:14 +00:00
|
|
|
//! 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`.
|
2015-05-31 09:59:43 +00:00
|
|
|
//!
|
|
|
|
//! ```toml
|
2021-07-12 07:48:17 +00:00
|
|
|
//! [dependencies]
|
2024-03-26 05:25:46 +00:00
|
|
|
//! yaml-rust2 = "0.8.0"
|
2015-05-31 09:59:43 +00:00
|
|
|
//! ```
|
|
|
|
//!
|
|
|
|
//! # Examples
|
2023-08-17 00:17:40 +00:00
|
|
|
//! Parse a string into `Vec<Yaml>` and then serialize it as a YAML string.
|
2015-05-31 09:59:43 +00:00
|
|
|
//!
|
|
|
|
//! ```
|
2024-02-08 06:12:14 +00:00
|
|
|
//! use yaml_rust2::{YamlLoader, YamlEmitter};
|
2015-05-31 09:59:43 +00:00
|
|
|
//!
|
|
|
|
//! let docs = YamlLoader::load_from_str("[1, 2, 3]").unwrap();
|
2023-08-17 00:17:40 +00:00
|
|
|
//! let doc = &docs[0]; // select the first YAML document
|
2015-05-31 09:59:43 +00:00
|
|
|
//! assert_eq!(doc[0].as_i64().unwrap(), 1); // access elements by index
|
2015-06-29 16:31:22 +00:00
|
|
|
//!
|
2015-05-31 09:59:43 +00:00
|
|
|
//! 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
|
|
|
|
//!
|
|
|
|
//! ```
|
2024-03-30 18:24:54 +00:00
|
|
|
//!
|
|
|
|
//! # Features
|
|
|
|
//! #### `encoding` (_enabled by default_)
|
|
|
|
//! Enables encoding-aware decoding of Yaml documents.
|
|
|
|
//!
|
|
|
|
//! This bumps MSRV up to `1.70.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.
|
|
|
|
//!
|
|
|
|
//! This bumps MSRV up to 1.70.0.
|
2015-05-31 09:59:43 +00:00
|
|
|
|
2024-03-20 14:50:48 +00:00
|
|
|
#![warn(missing_docs, clippy::pedantic)]
|
2024-03-19 17:18:59 +00:00
|
|
|
|
2020-05-26 10:35:06 +00:00
|
|
|
extern crate hashlink;
|
2016-03-20 05:06:44 +00:00
|
|
|
|
2024-01-24 00:02:20 +00:00
|
|
|
pub(crate) mod char_traits;
|
2024-01-24 01:22:02 +00:00
|
|
|
#[macro_use]
|
|
|
|
pub(crate) mod debug;
|
2015-05-31 04:56:45 +00:00
|
|
|
pub mod emitter;
|
2018-09-15 16:49:04 +00:00
|
|
|
pub mod parser;
|
|
|
|
pub mod scanner;
|
|
|
|
pub mod yaml;
|
2015-05-24 19:29:52 +00:00
|
|
|
|
2015-05-31 09:02:22 +00:00
|
|
|
// reexport key APIs
|
2020-05-27 06:15:28 +00:00
|
|
|
pub use crate::emitter::{EmitError, YamlEmitter};
|
|
|
|
pub use crate::parser::Event;
|
|
|
|
pub use crate::scanner::ScanError;
|
|
|
|
pub use crate::yaml::{Yaml, YamlLoader};
|