pub struct Config {
pub database: DatabaseConfig,
pub api: ApiConfig,
pub cache: CacheConfig,
pub stats: StatsConfig,
}
Expand description
Main configuration structure for cstats
Fields§
§database: DatabaseConfig
Database configuration
api: ApiConfig
API configuration
cache: CacheConfig
Cache configuration
stats: StatsConfig
Statistics configuration
Implementations§
Source§impl Config
impl Config
Sourcepub fn default_config_dir() -> Result<PathBuf>
pub fn default_config_dir() -> Result<PathBuf>
Get the default configuration directory path
Sourcepub fn default_config_path() -> Result<PathBuf>
pub fn default_config_path() -> Result<PathBuf>
Get the default configuration file path
Sourcepub async fn load_from_file(path: &Path) -> Result<Self>
pub async fn load_from_file(path: &Path) -> Result<Self>
Load configuration from file
Sourcepub async fn save_to_file(&self, path: &Path) -> Result<()>
pub async fn save_to_file(&self, path: &Path) -> Result<()>
Save configuration to file
Sourcepub async fn load() -> Result<Self>
pub async fn load() -> Result<Self>
Load configuration with priority: env vars > config file > defaults
Sourcepub async fn load_from_path(path: &Path) -> Result<Self>
pub async fn load_from_path(path: &Path) -> Result<Self>
Load configuration from a specific file path with env overrides
Sourcepub fn get_anthropic_api_key(&self) -> Option<&str>
pub fn get_anthropic_api_key(&self) -> Option<&str>
Get the Anthropic API key from config (use effective_anthropic_api_key for env priority)
Sourcepub fn has_anthropic_api_key(&self) -> bool
pub fn has_anthropic_api_key(&self) -> bool
Check if the configuration has a valid Anthropic API key
Sourcepub fn effective_anthropic_api_key(&self) -> Option<String>
pub fn effective_anthropic_api_key(&self) -> Option<String>
Get the effective Anthropic API key (env var takes precedence)
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more