All Projects → dtolnay → Serde Yaml

dtolnay / Serde Yaml

Licence: other
Strongly typed YAML library for Rust

Programming Languages

rust
11053 projects

Labels

Projects that are alternatives of or similar to Serde Yaml

Confuse
painless YAML config files for Python
Stars: ✭ 285 (-21.7%)
Mutual labels:  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
Awsweeper
A tool for cleaning your AWS account
Stars: ✭ 331 (-9.07%)
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
Yacron
A modern Cron replacement that is Docker-friendly
Stars: ✭ 302 (-17.03%)
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
Macos security
macOS Security Compliance Project
Stars: ✭ 348 (-4.4%)
Mutual labels:  yaml
Yaml
The Yaml component loads and dumps YAML files.
Stars: ✭ 3,359 (+822.8%)
Mutual labels:  yaml
Jk
Configuration as Code with ECMAScript
Stars: ✭ 322 (-11.54%)
Mutual labels:  yaml
Tmuxp
💻 tmux session manager. built on libtmux
Stars: ✭ 3,269 (+798.08%)
Mutual labels:  yaml
Jinja2 Cli
CLI for Jinja2
Stars: ✭ 302 (-17.03%)
Mutual labels:  yaml
Kubernetes Yaml Templates
Kubernetes Yaml Templates
Stars: ✭ 313 (-14.01%)
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
Dyff
/ˈdʏf/ - diff tool for YAML files, and sometimes JSON
Stars: ✭ 277 (-23.9%)
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
Yq
yq is a portable command-line YAML processor
Stars: ✭ 4,726 (+1198.35%)
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

github crates.io docs.rs build status

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(())
}

License

Licensed under either of Apache 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].