Skip to main content

noyalib_serde_yaml/
lib.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2// Copyright (c) 2026 Noyalib. All rights reserved.
3
4//! Drop-in `serde_yaml` replacement backed by
5//! [noyalib](https://docs.rs/noyalib) — **rename the package in
6//! `Cargo.toml`, change zero source lines**.
7//!
8//! ```toml
9//! # Cargo.toml — the whole migration:
10//! serde_yaml = { package = "noyalib-serde-yaml", version = "=0.0.58" }
11//! ```
12//!
13//! Every `use serde_yaml::…` in the codebase keeps compiling
14//! unchanged, and — since noyalib v0.0.29 made the shim
15//! *behavioural* — keeps behaving like `serde_yaml` 0.9 where it
16//! matters: `<<` merge keys stay literal entries, `0123` stays a
17//! string and `0b11` is 3, a literal `1e999` stays a string,
18//! `u64::MAX` keeps full precision and one past it refuses as
19//! `JSON number out of range`, non-scalar keys refuse as
20//! `invalid type: sequence, expected a string key`, alias expansion
21//! is budgeted with upstream's `repetition limit exceeded`, and
22//! parse errors carry libyaml's phrasing and end-of-input location
23//! convention. The 18-case contract suite pinning all of this —
24//! with expectations captured live from `serde_yaml 0.9.34` — ships
25//! in the core repository (`tests/serde_yaml_contract.rs`).
26//!
27//! Unlike the archived `serde_yaml` 0.9 this surface is maintained,
28//! pure-Rust with `#![forbid(unsafe_code)]`, and never re-introduces
29//! the unmaintained crate or its advisory chain as a dependency.
30//!
31//! # What this crate is
32//!
33//! A re-export of [`noyalib::compat::serde_yaml`] under a package
34//! name that Cargo's `package =` rename can substitute for
35//! `serde_yaml`. All engineering lives in noyalib; this crate pins
36//! the core at the identical `=0.0.X` and adds nothing else.
37//!
38//! # Examples
39//!
40//! ```
41//! // In a migrated project this line reads
42//! // `use serde_yaml::{from_str, to_string};` — unchanged from
43//! // before the migration.
44//! use noyalib_serde_yaml::{from_str, to_string};
45//!
46//! #[derive(serde::Serialize, serde::Deserialize, PartialEq, Debug)]
47//! struct Config {
48//!     name: String,
49//!     port: u16,
50//! }
51//!
52//! let cfg: Config = from_str("name: noyalib\nport: 8080\n").unwrap();
53//! assert_eq!(cfg.port, 8080);
54//! let back = to_string(&cfg).unwrap();
55//! let round: Config = from_str(&back).unwrap();
56//! assert_eq!(cfg, round);
57//! ```
58
59#![forbid(unsafe_code)]
60#![deny(missing_docs)]
61
62pub use noyalib::compat::serde_yaml::*;