use config::Config;
use serde::de::DeserializeOwned;
use super::{data::AppResult, server::application::AppConfig};
pub mod log;
pub mod registry;
pub mod security;
pub mod server;
pub trait ConfigExt {
fn get_or_default<T: DeserializeOwned + Default>(&self, key: &str) -> T;
}
impl ConfigExt for Config {
fn get_or_default<T: DeserializeOwned + Default>(&self, key: &str) -> T {
match self.get(key) {
Ok(v) => v,
Err(_) => T::default(),
}
}
}
#[async_trait]
pub trait UpdateableConfig {
async fn apply(&self, application: &AppConfig) -> AppResult<()>;
}