pub struct AppConfig {
pub providers: HashMap<String, ProviderSettings>,
}Expand description
App configuration, persisted at ~/.config/usage-monitor/config.toml.
Fields§
§providers: HashMap<String, ProviderSettings>Implementations§
Source§impl AppConfig
impl AppConfig
Sourcepub fn default_path() -> Option<PathBuf>
pub fn default_path() -> Option<PathBuf>
Default config path: $XDG_CONFIG_HOME/usage-monitor/config.toml
or ~/.config/usage-monitor/config.toml.
Sourcepub fn load_from_path(path: &Path) -> Result<Self, SpendPanelError>
pub fn load_from_path(path: &Path) -> Result<Self, SpendPanelError>
Loads the config from a path. A missing file yields the default config.
Sourcepub fn load() -> Result<Self, SpendPanelError>
pub fn load() -> Result<Self, SpendPanelError>
Loads the config from the default path (missing file → default config).
Sourcepub fn save_to_path(&self, path: &Path) -> Result<(), SpendPanelError>
pub fn save_to_path(&self, path: &Path) -> Result<(), SpendPanelError>
Saves the config as TOML, creating parent directories if needed.
Sourcepub fn provider_enabled(&self, id: &str) -> Option<bool>
pub fn provider_enabled(&self, id: &str) -> Option<bool>
Explicit provider-level toggle, if any.
Sourcepub fn set_provider_enabled(&mut self, id: &str, enabled: bool)
pub fn set_provider_enabled(&mut self, id: &str, enabled: bool)
Sets the explicit provider-level toggle.
Sourcepub fn clear_provider_enabled(&mut self, id: &str)
pub fn clear_provider_enabled(&mut self, id: &str)
Clears the explicit provider toggle, returning it to auto-detection.
Sourcepub fn resolve_state(
&self,
id: &str,
credentials_detected: bool,
) -> ProviderState
pub fn resolve_state( &self, id: &str, credentials_detected: bool, ) -> ProviderState
Resolves the state of a provider: explicit setting wins, otherwise falls back to credential detection or the presence of configured accounts.
Sourcepub fn has_accounts(&self, id: &str) -> bool
pub fn has_accounts(&self, id: &str) -> bool
True when the provider has at least one configured account.
Sourcepub fn account_ids(&self, id: &str) -> Vec<String>
pub fn account_ids(&self, id: &str) -> Vec<String>
Sorted account names configured for a provider (empty when none).
Sourcepub fn account(&self, id: &str, account: &str) -> Option<&AccountSettings>
pub fn account(&self, id: &str, account: &str) -> Option<&AccountSettings>
An account’s settings, if configured.
Sourcepub fn add_account(
&mut self,
id: &str,
account: &str,
label: Option<&str>,
) -> bool
pub fn add_account( &mut self, id: &str, account: &str, label: Option<&str>, ) -> bool
Creates an account (no-op if it already exists), returning whether it was newly created.
Sourcepub fn remove_account(&mut self, id: &str, account: &str) -> bool
pub fn remove_account(&mut self, id: &str, account: &str) -> bool
Removes an account entirely. Returns whether it existed.
Sourcepub fn set_account_label(&mut self, id: &str, account: &str, label: &str)
pub fn set_account_label(&mut self, id: &str, account: &str, label: &str)
Sets the account label.
Sourcepub fn set_account_config(
&mut self,
id: &str,
account: &str,
key: &str,
value: &str,
)
pub fn set_account_config( &mut self, id: &str, account: &str, key: &str, value: &str, )
Sets a key in an account’s table. The token key maps to the typed
field; everything else is stored flat.
Sourcepub fn unset_account_config(&mut self, id: &str, account: &str, key: &str)
pub fn unset_account_config(&mut self, id: &str, account: &str, key: &str)
Removes a key from an account’s table, cleaning up empty entries.
Sourcepub fn account_config(
&self,
id: &str,
account: &str,
) -> Option<&HashMap<String, String>>
pub fn account_config( &self, id: &str, account: &str, ) -> Option<&HashMap<String, String>>
An account’s flat config keys (excluding typed fields), if any.
Sourcepub fn account_token(&self, id: &str, account: &str) -> Option<&str>
pub fn account_token(&self, id: &str, account: &str) -> Option<&str>
An account’s auth token, if set.
Sourcepub fn account_workspaces(&self, id: &str, account: &str) -> &[String]
pub fn account_workspaces(&self, id: &str, account: &str) -> &[String]
An account’s workspace list (empty when unset).
Sourcepub fn set_account_workspaces(
&mut self,
id: &str,
account: &str,
workspaces: Vec<String>,
)
pub fn set_account_workspaces( &mut self, id: &str, account: &str, workspaces: Vec<String>, )
Replaces an account’s workspace list, cleaning up empty entries.
Sourcepub fn account_enabled(&self, id: &str, account: &str) -> Option<bool>
pub fn account_enabled(&self, id: &str, account: &str) -> Option<bool>
Explicit per-account toggle, if any.
Sourcepub fn set_account_enabled(&mut self, id: &str, account: &str, enabled: bool)
pub fn set_account_enabled(&mut self, id: &str, account: &str, enabled: bool)
Sets the explicit per-account toggle.
Sourcepub fn clear_account_enabled(&mut self, id: &str, account: &str)
pub fn clear_account_enabled(&mut self, id: &str, account: &str)
Clears the explicit per-account toggle, cleaning up empty entries.
Sourcepub fn account_is_enabled(&self, id: &str, account: &str) -> bool
pub fn account_is_enabled(&self, id: &str, account: &str) -> bool
True when the account is enabled (explicit toggle wins, else enabled).