machines/rust/lib/common/src/yaml.rs

11 lines
308 B
Rust
Raw Normal View History

use anyhow::Context;
use serde::Serialize;
pub fn string(str: &str) -> String {
serde_yml::to_string(str).expect("Should be able to encode string")
}
pub fn to_string<T: ?Sized + Serialize>(value: &T) -> anyhow::Result<String> {
serde_yml::to_string(value).context("Could not serialize to yaml")
}