69 lines
1.8 KiB
Rust
69 lines
1.8 KiB
Rust
use std::time::Duration;
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct ChurchCoreConfig {
|
|
pub api_base_url: String,
|
|
pub cache_ttl: Duration,
|
|
pub timeout: Duration,
|
|
pub connect_timeout: Duration,
|
|
pub retry_attempts: u32,
|
|
pub enable_offline_mode: bool,
|
|
pub max_cache_size: usize,
|
|
pub user_agent: String,
|
|
}
|
|
|
|
impl Default for ChurchCoreConfig {
|
|
fn default() -> Self {
|
|
Self {
|
|
api_base_url: "https://api.rockvilletollandsda.church".to_string(),
|
|
cache_ttl: Duration::from_secs(300), // 5 minutes
|
|
timeout: Duration::from_secs(10),
|
|
connect_timeout: Duration::from_secs(5),
|
|
retry_attempts: 3,
|
|
enable_offline_mode: true,
|
|
max_cache_size: 1000,
|
|
user_agent: format!("church-core/{}", env!("CARGO_PKG_VERSION")),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl ChurchCoreConfig {
|
|
pub fn new() -> Self {
|
|
Self::default()
|
|
}
|
|
|
|
pub fn with_base_url(mut self, url: impl Into<String>) -> Self {
|
|
self.api_base_url = url.into();
|
|
self
|
|
}
|
|
|
|
pub fn with_cache_ttl(mut self, ttl: Duration) -> Self {
|
|
self.cache_ttl = ttl;
|
|
self
|
|
}
|
|
|
|
pub fn with_timeout(mut self, timeout: Duration) -> Self {
|
|
self.timeout = timeout;
|
|
self
|
|
}
|
|
|
|
pub fn with_retry_attempts(mut self, attempts: u32) -> Self {
|
|
self.retry_attempts = attempts;
|
|
self
|
|
}
|
|
|
|
pub fn with_offline_mode(mut self, enabled: bool) -> Self {
|
|
self.enable_offline_mode = enabled;
|
|
self
|
|
}
|
|
|
|
pub fn with_max_cache_size(mut self, size: usize) -> Self {
|
|
self.max_cache_size = size;
|
|
self
|
|
}
|
|
|
|
pub fn with_user_agent(mut self, agent: impl Into<String>) -> Self {
|
|
self.user_agent = agent.into();
|
|
self
|
|
}
|
|
} |