1#![doc = include_str!("../README.md")]
2
3mod config;
4mod output;
5mod ty;
6mod value;
7
8#[cfg(test)]
9mod tests;
10
11use toml_edit::TomlError;
12
13pub use self::config::{Config, ConfigItem};
14pub use self::output::OutputFormat;
15pub use self::ty::ConfigType;
16pub use self::value::ConfigValue;
17
18pub enum ConfigErr {
20 Parse(TomlError),
22 InvalidValue,
24 InvalidType,
26 ValueTypeMismatch,
28 Other(String),
30}
31
32impl From<TomlError> for ConfigErr {
33 fn from(e: TomlError) -> Self {
34 Self::Parse(e)
35 }
36}
37
38impl core::fmt::Display for ConfigErr {
39 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
40 match self {
41 Self::Parse(e) => write!(f, "{}", e),
42 Self::InvalidValue => write!(f, "Invalid config value"),
43 Self::InvalidType => write!(f, "Invalid config type"),
44 Self::ValueTypeMismatch => write!(f, "Config value and type mismatch"),
45 Self::Other(s) => write!(f, "{}", s),
46 }
47 }
48}
49
50impl core::fmt::Debug for ConfigErr {
51 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
52 write!(f, "{}", self)
53 }
54}
55
56pub type ConfigResult<T> = Result<T, ConfigErr>;