You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

32 lines
724 B

#[blonkus_ma::serialize_config]
#[derive(Default)]
pub struct Conf {
pub render: crate::render::conf::Conf,
}
#[derive(thiserror::Error, Debug)]
pub enum ErrConfLoad {
#[error("No existing configuration file")]
NoFile,
#[error("Couldn't open configuration file `{0}'")]
File(std::io::Error),
#[error("Couldn't parse configuration file `{0}'")]
Parse(#[from] toml::de::Error),
}
impl From<std::io::Error> for ErrConfLoad {
fn from(err: std::io::Error) -> Self {
match err.kind() {
| std::io::ErrorKind::NotFound => Self::NoFile,
| _ => Self::File(err),
}
}
}
impl Conf {
pub fn read(path: &'static str) -> Result<Self, ErrConfLoad> {
Ok(toml::from_str(&std::fs::read_to_string(path)?)?)
}
}
// EOF