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-02-08 06:12:14 +00:00
|
|
|
//! yaml-rust2 = "0.5.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-02-08 06:12:14 +00:00
|
|
|
#![doc(html_root_url = "https://docs.rs/yaml-rust2/0.5.0")]
|
2023-08-11 23:54:46 +00:00
|
|
|
#![cfg_attr(feature = "cargo-clippy", warn(clippy::pedantic))]
|
2018-09-15 17:06:46 +00:00
|
|
|
#![cfg_attr(
|
|
|
|
feature = "cargo-clippy",
|
2023-08-11 23:54:46 +00:00
|
|
|
allow(
|
|
|
|
clippy::match_same_arms,
|
|
|
|
clippy::should_implement_trait,
|
|
|
|
clippy::missing_errors_doc,
|
|
|
|
clippy::missing_panics_doc,
|
|
|
|
clippy::redundant_else,
|
|
|
|
)
|
2018-09-15 17:06:46 +00:00
|
|
|
)]
|
2016-02-28 00:30:13 +00:00
|
|
|
|
2016-03-20 05:06:44 +00:00
|
|
|
extern crate linked_hash_map;
|
|
|
|
|
2024-01-24 00:02:20 +00:00
|
|
|
pub(crate) mod char_traits;
|
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};
|