• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/workflows/H03-May-2022-5750

src/H03-May-2022-5,8834,083

tests/H03-May-2022-1,2421,105

.cargo-checksum.jsonH A D03-May-202289 11

.cargo_vcs_info.jsonH A D01-Jan-197074 65

.clippy.tomlH A D29-Nov-197316 21

.gitignoreH A D29-Nov-197318 32

Cargo.tomlH A D01-Jan-19701.1 KiB4437

Cargo.toml.orig-cargoH A D29-Nov-1973617 2622

LICENSE-APACHEH A D29-Nov-197310.6 KiB202169

LICENSE-MITH A D29-Nov-19731,023 2421

README.mdH A D29-Nov-19733.9 KiB10576

README.md

1Serde YAML
2==========
3
4[<img alt="github" src="https://img.shields.io/badge/github-dtolnay/serde--yaml-8da0cb?style=for-the-badge&labelColor=555555&logo=github" height="20">](https://github.com/dtolnay/serde-yaml)
5[<img alt="crates.io" src="https://img.shields.io/crates/v/serde_yaml.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20">](https://crates.io/crates/serde_yaml)
6[<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-serde__yaml-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K" height="20">](https://docs.rs/serde_yaml)
7[<img alt="build status" src="https://img.shields.io/github/workflow/status/dtolnay/serde-yaml/CI/master?style=for-the-badge" height="20">](https://github.com/dtolnay/serde-yaml/actions?query=branch%3Amaster)
8
9This crate is a Rust library for using the [Serde] serialization framework with
10data in [YAML] file format.
11
12[Serde]: https://github.com/serde-rs/serde
13[YAML]: https://yaml.org/
14
15This library does not reimplement a YAML parser; it uses [yaml-rust] which is a
16pure Rust YAML 1.2 implementation.
17
18[yaml-rust]: https://github.com/chyh1990/yaml-rust
19
20## Dependency
21
22```toml
23[dependencies]
24serde = "1.0"
25serde_yaml = "0.8"
26```
27
28Release notes are available under [GitHub releases].
29
30[GitHub releases]: https://github.com/dtolnay/serde-yaml/releases
31
32## Using Serde YAML
33
34[API documentation is available in rustdoc form][docs.rs] but the general idea
35is:
36
37[docs.rs]: https://docs.rs/serde_yaml
38
39```rust
40use std::collections::BTreeMap;
41
42fn main() -> Result<(), serde_yaml::Error> {
43    // You have some type.
44    let mut map = BTreeMap::new();
45    map.insert("x".to_string(), 1.0);
46    map.insert("y".to_string(), 2.0);
47
48    // Serialize it to a YAML string.
49    let s = serde_yaml::to_string(&map)?;
50    assert_eq!(s, "---\nx: 1.0\ny: 2.0\n");
51
52    // Deserialize it back to a Rust type.
53    let deserialized_map: BTreeMap<String, f64> = serde_yaml::from_str(&s)?;
54    assert_eq!(map, deserialized_map);
55    Ok(())
56}
57```
58
59It can also be used with Serde's derive macros to handle structs and enums
60defined by your program.
61
62```toml
63[dependencies]
64serde = { version = "1.0", features = ["derive"] }
65serde_yaml = "0.8"
66```
67
68```rust
69use serde::{Serialize, Deserialize};
70
71#[derive(Debug, PartialEq, Serialize, Deserialize)]
72struct Point {
73    x: f64,
74    y: f64,
75}
76
77fn main() -> Result<(), serde_yaml::Error> {
78    let point = Point { x: 1.0, y: 2.0 };
79
80    let s = serde_yaml::to_string(&point)?;
81    assert_eq!(s, "---\nx: 1.0\ny: 2.0");
82
83    let deserialized_point: Point = serde_yaml::from_str(&s)?;
84    assert_eq!(point, deserialized_point);
85    Ok(())
86}
87```
88
89<br>
90
91#### License
92
93<sup>
94Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
952.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option.
96</sup>
97
98<br>
99
100<sub>
101Unless you explicitly state otherwise, any contribution intentionally submitted
102for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
103be dual licensed as above, without any additional terms or conditions.
104</sub>
105