pub enum ConfigScope {
Preferences,
UserGlobal,
ProjectLocal,
LocalData,
PersistentData,
Runtime,
}Expand description
Configuration scope representing different layers of configuration sources.
The scope system allows applications to organize configuration across multiple layers with clear precedence: defaults → user prefs → global config → project config → local data → persistent data → runtime overrides.
§Scopes
- Preferences: User application preferences (via
BaseDirs::preference_dir()) - UserGlobal: User configuration applying across all projects (via
ProjectDirs::config_dir()) - ProjectLocal: Project-specific configuration (current directory)
- LocalData: Machine-local data not synced across machines (via
BaseDirs::data_local_dir()) - PersistentData: Cross-machine persistent application state (via
BaseDirs::data_dir()) - Runtime: Dynamic configuration from environment variables and CLI (not file-based)
§Precedence Order
When using MultiScopeConfig, scopes are typically loaded in this order:
- Preferences
- UserGlobal
- ProjectLocal
- LocalData
- PersistentData
- Runtime (env vars + CLI, handled separately)
Later scopes override earlier ones during configuration merging.
§Example
use settings_loader::ConfigScope;
let scopes = vec![
ConfigScope::Preferences,
ConfigScope::UserGlobal,
ConfigScope::ProjectLocal,
];
// Use in collections
let mut scope_map = std::collections::HashMap::new();
scope_map.insert(ConfigScope::Preferences, "user prefs");Variants§
Preferences
User application preferences
Platform-specific locations:
- Linux:
~/.config/APP_NAME(or XDG_CONFIG_HOME/APP_NAME) - macOS:
~/Library/Preferences/APP_NAME - Windows:
%APPDATA%/APP_NAME
UserGlobal
User configuration applying across all projects
Platform-specific locations:
- Linux:
~/.config/APP_NAME(or XDG_CONFIG_HOME/APP_NAME) - macOS:
~/Library/Application Support/ORG_NAME.APP_NAME - Windows:
%APPDATA%/ORG_NAME/APP_NAME
ProjectLocal
Project-specific configuration in current directory
Location: ./settings.{ext} (any supported format)
Searchable with find_config_in().
LocalData
Machine-local data not synced across machines
Platform-specific locations:
- Linux:
~/.cache/APP_NAME(or XDG_CACHE_HOME/APP_NAME) - macOS:
~/Library/Caches/ORG_NAME.APP_NAME - Windows:
%LOCALAPPDATA%/ORG_NAME/APP_NAME
Use for ephemeral data, caches, runtime state.
PersistentData
Cross-machine persistent application state
Platform-specific locations:
- Linux:
~/.local/share/APP_NAME(or XDG_DATA_HOME/APP_NAME) - macOS:
~/Library/Application Support/ORG_NAME.APP_NAME - Windows:
%APPDATA%/ORG_NAME/APP_NAME
Use for persistent data that should sync across machines.
Runtime
Dynamic configuration from environment variables and CLI
Not file-based. Resolved separately via environment variables
and command-line arguments. resolve_path() returns None for this scope.
Implementations§
Source§impl ConfigScope
impl ConfigScope
Trait Implementations§
Source§impl Clone for ConfigScope
impl Clone for ConfigScope
Source§fn clone(&self) -> ConfigScope
fn clone(&self) -> ConfigScope
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more