feat: Added DiscordConfig for future usage

- Added crate::error::Error::IsNotImplemented
- Added Config::full_impl_path
- Added Config::discord_impl for discord crate
This commit is contained in:
Alexey 2025-12-09 16:07:41 +03:00
commit b92eaa1241
4 changed files with 106 additions and 1 deletions

View file

@ -357,4 +357,19 @@ impl Config {
path.push(self.map.clone());
path
}
/// Returns full path to implementation config TOML, if defined
/// This path will be relative to working directory
/// Only makes sense if using inside binary crate,
/// which provides implementation config
pub fn full_impl_path(&self) -> Option<PathBuf> {
match &self.impl_path {
Some(impl_path) => {
let mut path = self.path.clone();
path.push(impl_path.clone());
Some(path)
},
None => None,
}
}
}

View file

@ -15,6 +15,8 @@ pub enum Error {
TomlSerializeError(toml::ser::Error),
/// toml::de::Error happened when loading
TomlDeserializeError(toml::de::Error),
/// Implementation config is None, so crate binary is not implemented.
IsNotImplemented,
}
impl fmt::Display for Error {
@ -24,6 +26,7 @@ impl fmt::Display for Error {
Self::IoError(error) => write!(f, "{error}"),
Self::TomlSerializeError(error) => write!(f, "{error}"),
Self::TomlDeserializeError(error) => write!(f, "{error}"),
Self::IsNotImplemented => write!(f, "implementation not found"),
}
}
}