API Reference

serde_yaml

YAML serialization and deserialization for Rust built on serde and a libyaml-derived parser.

Official Documentation ↗
CompatibilityThis documentation covers version v0.9. Check the official docs for the latest API surface.

Installation

cargocargo add serde_yaml

Methods

serde_yaml maps YAML documents to Rust structs and back through serde derives.

Key Features

  • Struct mapping with serde derives
  • Value type for untyped access
  • Multi-document streams

Usage Notes

Pin a version and check the official docs for the API surface you depend on before upgrading.

Errors

The following points are quoted verbatim from the official documentation. 来源:https://docs.rs/serde_yaml/latest/serde_yaml/ · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:52:26.589Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.

FAQ

How do I read several documents?
Use Deserializer::from_str and iterate over the documents, decoding each one into your type.
How do I rename fields?
Use serde attributes such as #[serde(rename = "name")] on the struct fields.
Should I use serde_yaml in production?
It is deprecated upstream; for new code prefer a maintained alternative, but it remains widely used in existing projects.