use std::ops::Deref;
use std::sync::Arc;
use serde::Deserialize;
use serde::Serialize;
use trz_gateway_common::dynamic_config::DynamicConfig;
use trz_gateway_common::dynamic_config::has_diff::DiffArc;
use super::types::ConfigTypes;
use super::types::Password;
use super::types::RuntimeTypes;
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct ServerConfig<T: ConfigTypes = RuntimeTypes> {
pub host: T::String,
pub ports: T::Ports,
#[serde(rename = "terminal-shell", alias = "terminal_shell")]
pub terminal_shell: Option<String>,
pub trash: T::Path,
#[serde(rename = "git-trash", alias = "git_trash")]
pub git_trash: T::MaybePath,
pub set_current_endpoint: T::MaybePath,
pub pidfile: T::Path,
pub private_root_ca: T::Path,
pub password: Option<Password>,
pub token_lifetime: T::Duration,
pub token_refresh: T::Duration,
pub config_file_watcher: T::MaybeBool,
pub config_file_poll_strategy: T::MaybeRetryStrategy,
pub certificate_renewal_threshold: T::Duration,
}
#[derive(Clone)]
pub struct DynamicServerConfig(pub(super) Arc<DynamicConfig<DiffArc<ServerConfig>>>);
impl Deref for DynamicServerConfig {
type Target = Arc<DynamicConfig<DiffArc<ServerConfig>>>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<Arc<DynamicConfig<DiffArc<ServerConfig>>>> for DynamicServerConfig {
fn from(value: Arc<DynamicConfig<DiffArc<ServerConfig>>>) -> Self {
Self(value)
}
}