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

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

/// Postcard format parser using `postcard`.
pub struct Postcard;

impl Format for Postcard {
	fn extensions(&self) -> &'static [&'static str] {
		&["bin", "post"]
	}

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