Skip to content

Documentation

ayaml is a pure-Rust YAML 1.2.2 parser, spanned event stream, generic value model, Serde codec, and deterministic emitter.

One scanner and grammar back every public surface, so event streams, Value trees, flat-array Tape documents, typed Serde reads, SpannedTree lookups, and emitted YAML share the same syntax rules, byte-accurate spans, and resource limits. Published workspace crates forbid unsafe code and depend only on serde and indexmap.

[dependencies]
ayaml = "1.0.0"

For derived Serde types, enable Serde’s derive feature in your crate:

[dependencies]
ayaml = "1.0.0"
serde = { version = "1", features = ["derive"] }

For verified, source-preserving edits, add the companion crate:

[dependencies]
ayaml-edit = "1.0.0"

The minimum supported Rust version is Rust 1.88.

Parse into Value or decode directly into typed Rust structs, then emit deterministic YAML:

use serde::{Deserialize, Serialize};
#[derive(Debug, PartialEq, Deserialize, Serialize)]
struct Service {
name: String,
ports: Vec<u16>,
}
let input = "name: api\nports:\n - 8080\n - 8443\n";
let service: Service = ayaml::from_str(input)?;
assert_eq!(service.name, "api");
assert_eq!(service.ports, vec![8080, 8443]);
let rendered = ayaml::to_string(&service)?;
assert_eq!(ayaml::from_str::<Service>(&rendered)?, service);
Topic Page
Parsing, typed Serde reads, events, spans, options, and emitting Getting started
Streaming, tags, merges, Spanned<T>, frontmatter, and middleware Cookbook
Comment-preserving verified edits with ayaml-edit Source-preserving editing (ayaml-edit)
Migrating from serde_yaml (archived libyaml Serde crate) Migrating from serde_yaml
Migrating from serde_yml, serde_yaml_ng, or yaml-serde Migrating from libyaml forks
Migrating from yaml-rust2, saphyr, or serde-saphyr Migrating from yaml-rust2 / saphyr
End-to-end migration benchmarks and findings on five open-source Rust projects Real-world migration validation
Moving from YAML 1.1 scalars, duplicate keys, and merge keys Migrating from YAML 1.1
Choosing Limits profiles for untrusted payloads and large schemas Sizing resource limits
Format contract layers, spans, positions, and locations Format contract and interface
YAML 1.2.2 profile and optional libyaml-compat mode Compatibility profile
Complete public API map, feature flags, and caveats API reference and caveats
Stable ErrorCode catalog and masked error output Error codes
Threat model, untrusted input, resource limits, and error text Security and untrusted input
Testing, fuzzing, Miri, Kani proofs, mutation testing, and release checks Correctness and verification
Stable, #[non_exhaustive], removed 0.x, and unstable API surfaces Stability and versioning
Detailed resource limit ceilings, accounting rules, and memory bounds Resource limits
Benchmark results and comparison tables Benchmarks
Visual guide to Tape DOM, Value DOM, pull events, and C++ arenas Parsing modes explained
Reproducible harness methodology and cargo xtask Benchmark methodology
Conformance, fuzzing, Kani, Miri, and mutation tooling Developer tooling and verification
Generated Rust API reference docs.rs/ayaml · docs.rs/ayaml-edit