dtolnay / Serde Yaml
Licence: other
Strongly typed YAML library for Rust
Stars: ✭ 364
Programming Languages
rust
11053 projects
Projects that are alternatives of or similar to Serde Yaml
Esphome
ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems.
Stars: ✭ 4,324 (+1087.91%)
Mutual labels: yaml
Envfile
EnvFile 3.0 is a plugin for JetBrains IDEs that allows you to set environment variables for your run configurations from one or multiple files.
Stars: ✭ 293 (-19.51%)
Mutual labels: yaml
Rustbreak
A simple, fast and easy to use self-contained single file storage for Rust
Stars: ✭ 315 (-13.46%)
Mutual labels: yaml
Korio
Korio: Kotlin cORoutines I/O : Virtual File System + Async/Sync Streams + Async TCP Client/Server + WebSockets for Multiplatform Kotlin 1.3
Stars: ✭ 282 (-22.53%)
Mutual labels: yaml
Json Schema Validator
A fast Java JSON schema validator that supports draft V4, V6, V7 and V2019-09
Stars: ✭ 292 (-19.78%)
Mutual labels: yaml
Pico
Pico is a stupidly simple, blazing fast, flat file CMS.
Stars: ✭ 3,494 (+859.89%)
Mutual labels: yaml
Grabana
User-friendly Go library for building Grafana dashboards
Stars: ✭ 313 (-14.01%)
Mutual labels: yaml
Grow
A declarative website generator designed for high-quality websites, with a focus on easy maintenance and localization.
Stars: ✭ 360 (-1.1%)
Mutual labels: yaml
Hoplite
A boilerplate-free library for loading configuration files as data classes in Kotlin
Stars: ✭ 322 (-11.54%)
Mutual labels: yaml
Serde YAML
This crate is a Rust library for using the Serde serialization framework with data in YAML file format.
This library does not reimplement a YAML parser; it uses yaml-rust which is a pure Rust YAML 1.2 implementation.
Dependency
[dependencies]
serde = "1.0"
serde_yaml = "0.8"
Release notes are available under GitHub releases.
Using Serde YAML
API documentation is available in rustdoc form but the general idea is:
use std::collections::BTreeMap;
fn main() -> Result<(), serde_yaml::Error> {
// You have some type.
let mut map = BTreeMap::new();
map.insert("x".to_string(), 1.0);
map.insert("y".to_string(), 2.0);
// Serialize it to a YAML string.
let s = serde_yaml::to_string(&map)?;
assert_eq!(s, "---\nx: 1.0\ny: 2.0\n");
// Deserialize it back to a Rust type.
let deserialized_map: BTreeMap<String, f64> = serde_yaml::from_str(&s)?;
assert_eq!(map, deserialized_map);
Ok(())
}
It can also be used with Serde's derive macros to handle structs and enums defined by your program.
[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_yaml = "0.8"
use serde::{Serialize, Deserialize};
#[derive(Debug, PartialEq, Serialize, Deserialize)]
struct Point {
x: f64,
y: f64,
}
fn main() -> Result<(), serde_yaml::Error> {
let point = Point { x: 1.0, y: 2.0 };
let s = serde_yaml::to_string(&point)?;
assert_eq!(s, "---\nx: 1.0\ny: 2.0");
let deserialized_point: Point = serde_yaml::from_str(&s)?;
assert_eq!(point, deserialized_point);
Ok(())
}
Licensed under either of LicenseApache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].