---
title: "oneyaml for Rust"
url: https://recursiveai.org/oneyaml/rust/
description: "Typed reads with serde and lossless, comment-preserving edits for YAML 1.2, in one crate. No unsafe, no panics on any input. MIT or Apache-2.0."
---

# oneyaml for Rust

Typed reads with serde and lossless, comment-preserving edits for YAML 1.2, in one crate.

```sh
cargo add oneyaml
```

## A quick look

Read typed data with serde, then edit the document in place. The edit changes only what you touched, and the comment stays.

[Full docs on docs.rs](https://docs.rs/oneyaml)

*main.rs · Rust*

```
// serde: typed reads and writes
let cfg: Config = oneyaml::from_str(text)?;
 
// The lossless document: edit in place
let mut doc = Document::parse(text)?;
doc.set_path("server.port", 9090)?;
// Everything else, comments included,
// stays byte for byte.
```

## The crate

- **Conformance**: 402 of 402 cases on the yaml-test-suite.
- **Safety**: No `unsafe`, no panics on any input, and a `Limits::untrusted()` profile for network input. Fuzzed.
- **Rust**: 1.85 or newer.
- **License**: MIT or Apache-2.0.

## Go further

- [GitHub](https://github.com/recursive-ai-oss/oneyaml-rust)
- [crates.io](https://crates.io/crates/oneyaml)
- [docs.rs](https://docs.rs/oneyaml)
- [Moving from serde_yaml](https://github.com/recursive-ai-oss/oneyaml-rust/blob/main/docs/migrating-from-serde-yaml.md)
- [The specification](https://recursiveai.org/oneyaml/spec/)
