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/json.rs */

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

/// JSON format parser using `serde_json`.
pub struct Json;

impl Format for Json {
	fn extensions(&self) -> &'static [&'static str] {
		&["json"]
	}

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