use serde::{Deserialize, Serialize};
use std::fmt::{Debug, Display, Formatter};
pub trait OgreRootConfig: Debug + Serialize + for<'r> Deserialize<'r> + Sized + Default {}
pub trait CmdLineAndConfigIntegration<RootConfigType: OgreRootConfig>: clap::Parser + Debug {
fn config_file_path(&self) -> Option<&str>;
fn should_write_effective_config(&self) -> bool;
fn should_show_effective_config(&self) -> bool;
fn merge_with_config(self, config: RootConfigType) -> RootConfigType;
}
#[derive(Debug)]
pub enum Error {
LoadingConfig {
message: String,
cause: Box<dyn std::error::Error + Send + Sync>,
},
SavingConfig {
message: String,
cause: Box<dyn std::error::Error + Send + Sync>,
},
UnsupportedConfigFileFormat {
message: String,
},
Ron {
message: String,
cause: ron::Error,
},
Yaml {
message: String,
cause: serde_yaml::Error,
},
Io {
message: String,
cause: std::io::Error,
},
}
impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
<Self as Debug>::fmt(self, f)
}
}
impl std::error::Error for Error {}