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:
parent
1142fe6ad9
commit
b92eaa1241
4 changed files with 106 additions and 1 deletions
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue