use std::time::Duration;
#[derive(Debug, Clone)]
pub struct GatewardenConfig {
pub app_name: String,
pub feature_name: String,
pub account_id: String,
pub public_key_hex: String,
pub required_entitlements: Vec<String>,
pub user_agent_product: String,
pub cache_namespace: String,
pub offline_grace: Duration,
}
impl GatewardenConfig {
pub fn validate(&self) -> Result<(), crate::GatewardenError> {
if self.account_id.is_empty() {
return Err(crate::GatewardenError::ConfigError(
"account_id cannot be empty".to_string(),
));
}
if self.public_key_hex.len() != 64 {
return Err(crate::GatewardenError::ConfigError(format!(
"public_key_hex must be 64 hex characters, got {}",
self.public_key_hex.len()
)));
}
if self.cache_namespace.is_empty() {
return Err(crate::GatewardenError::ConfigError(
"cache_namespace cannot be empty".to_string(),
));
}
Ok(())
}
}