live 0.3.1

A modular configuration framework with live reloading and atomic, format-agnostic updates.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* src/loader/format/yaml.rs */

use super::super::{FmtError, Format};
use serde::de::DeserializeOwned;

/// YAML format parser using `serde_yaml`.
pub struct Yaml;

impl Format for Yaml {
	fn extensions(&self) -> &'static [&'static str] {
		&["yaml", "yml"]
	}

	fn parse<T: DeserializeOwned>(&self, input: &[u8]) -> Result<T, FmtError> {
		serde_yaml::from_slice(input).map_err(|e| FmtError::ParseError(e.to_string()))
	}
}