1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#![allow(missing_docs)] use crate::config::Config;
use crate::error::{
Error,
Result,
};
use rust_embed::RustEmbed;
use std::str;
#[derive(Debug, RustEmbed)]
#[folder = "config/"]
pub struct EmbeddedConfig;
impl EmbeddedConfig {
pub fn get_config() -> Result<String> {
match Self::get(crate::DEFAULT_CONFIG) {
Some(v) => Ok(str::from_utf8(&v.data)?.to_string()),
None => Err(Error::EmbeddedError(String::from(
"Embedded config not found",
))),
}
}
pub fn parse() -> Result<Config> {
Ok(toml::from_str(&Self::get_config()?)?)
}
}