Crate serializable_yaml

Crate serializable_yaml 

Source
Expand description

This library makes yaml-rust’s YAML enum serializable.

Because of the orphan rule we cannot implement the necessary trait on the YAML enum directly, so instead this library provides its own serializable equivalent with the same name.

For (de)serialization of custom Rust types to/from YAML see serde_yaml.

§Usage

let input = "answer: 42";
// load some YAML with yaml-rust
let yaml = yaml_rust::YamlLoader::load_from_str(input).unwrap();
// convert it to the serializable-yaml equivalent
let yaml = serializable_yaml::from_vec(yaml);
// you can now serialize tha YAML instance with serde_yaml
let yaml_as_string = serde_yaml::to_string(&yaml).unwrap();

Utility functions from_vec and from_map are also available.

Enums§

Yaml
A serializable equivalent of the yaml_rust::Yaml enum. The main difference being that only strings are allowed as hashmap keys.

Functions§

from_map
from_map_ref
from_slice
from_vec