pub struct ConfigurationManager {
ConfigPath: Option<PathBuf>,
BackupDir: Option<PathBuf>,
EnableBackup: bool,
EnvPrefix: String,
}Expand description
Configuration manager with comprehensive validation, backup, and hot-reload support
Fields§
§ConfigPath: Option<PathBuf>Path to configuration file
BackupDir: Option<PathBuf>Backup configuration directory
EnableBackup: boolEnable configuration backup
EnvPrefix: StringEnvironment variable prefix for overrides
Implementations§
Source§impl ConfigurationManager
impl ConfigurationManager
Sourcepub fn NewWithSettings(
ConfigPath: Option<String>,
EnableBackup: bool,
EnvPrefix: String,
) -> Result<Self>
pub fn NewWithSettings( ConfigPath: Option<String>, EnableBackup: bool, EnvPrefix: String, ) -> Result<Self>
Create a new configuration manager with custom settings
§Arguments
ConfigPath- Optional path to configuration fileEnableBackup- Whether to enable automatic backupsEnvPrefix- Prefix for environment variable overrides
Sourcepub async fn LoadConfiguration(&self) -> Result<AirConfiguration>
pub async fn LoadConfiguration(&self) -> Result<AirConfiguration>
Load configuration from file, environment, or create default
This method implements the configuration priority chain:
- Defaults from code
- Configuration file
- Environment variables (with prefix)
§Returns
Validated and loaded configuration
Sourceasync fn LoadFromFile(&self, path: &Path) -> Result<AirConfiguration>
async fn LoadFromFile(&self, path: &Path) -> Result<AirConfiguration>
Sourcepub async fn SaveConfiguration(&self, config: &AirConfiguration) -> Result<()>
pub async fn SaveConfiguration(&self, config: &AirConfiguration) -> Result<()>
Sourcefn ValidateConfiguration(&self, config: &AirConfiguration) -> Result<()>
fn ValidateConfiguration(&self, config: &AirConfiguration) -> Result<()>
Validate configuration with comprehensive checks
Performs:
- Schema validation
- Type checking with detailed errors
- Range validation for numeric values
- Path validation for security
- URL validation for network resources
Sourcefn ValidateSchemaVersion(&self, version: &str) -> Result<()>
fn ValidateSchemaVersion(&self, version: &str) -> Result<()>
Validate schema version format
Sourcefn ValidateProfile(&self, profile: &str) -> Result<()>
fn ValidateProfile(&self, profile: &str) -> Result<()>
Validate profile name
Sourcefn ValidategRPCConfig(&self, grpc: &gRPCConfig) -> Result<()>
fn ValidategRPCConfig(&self, grpc: &gRPCConfig) -> Result<()>
Validate gRPC configuration with range checking
Sourcefn ValidateAuthConfig(&self, auth: &AuthConfig) -> Result<()>
fn ValidateAuthConfig(&self, auth: &AuthConfig) -> Result<()>
Validate authentication configuration
Sourcefn ValidateUpdateConfig(&self, updates: &UpdateConfig) -> Result<()>
fn ValidateUpdateConfig(&self, updates: &UpdateConfig) -> Result<()>
Validate update configuration
Sourcefn ValidateDownloadConfig(&self, downloader: &DownloadConfig) -> Result<()>
fn ValidateDownloadConfig(&self, downloader: &DownloadConfig) -> Result<()>
Validate download configuration
Sourcefn ValidateIndexingConfig(&self, indexing: &IndexingConfig) -> Result<()>
fn ValidateIndexingConfig(&self, indexing: &IndexingConfig) -> Result<()>
Validate indexing configuration
Sourcefn ValidateLoggingConfig(&self, logging: &LoggingConfig) -> Result<()>
fn ValidateLoggingConfig(&self, logging: &LoggingConfig) -> Result<()>
Validate logging configuration
Sourcefn ValidatePerformanceConfig(
&self,
performance: &PerformanceConfig,
) -> Result<()>
fn ValidatePerformanceConfig( &self, performance: &PerformanceConfig, ) -> Result<()>
Validate performance configuration
Sourcefn ValidatePath(&self, path: &str) -> Result<()>
fn ValidatePath(&self, path: &str) -> Result<()>
Validate path for security (prevent directory traversal)
Sourcefn IsValidAddress(addr: &str) -> bool
fn IsValidAddress(addr: &str) -> bool
Validate address format (IP:port or hostname:port)
Sourcefn IsValidUrl(url: &str) -> bool
fn IsValidUrl(url: &str) -> bool
Validate URL format
Sourcefn SchemaValidate(&self, config: &AirConfiguration) -> Result<()>
fn SchemaValidate(&self, config: &AirConfiguration) -> Result<()>
Perform schema-based validation
Sourcefn ApplyEnvironmentOverrides(&self, config: &mut AirConfiguration) -> Result<()>
fn ApplyEnvironmentOverrides(&self, config: &mut AirConfiguration) -> Result<()>
Apply environment variable overrides to configuration
Environment variables are read with the configured prefix. For example, with prefix “AIR_”, the variable “AIR_GRPC_BIND_ADDRESS” would override grpc.bind_address.
Variable naming convention: {PREFIX}{SECTION}{FIELD} (uppercase, underscores)
Sourceasync fn BackupConfiguration(&self, config_path: &Path) -> Result<()>
async fn BackupConfiguration(&self, config_path: &Path) -> Result<()>
Backup current configuration file
Creates a timestamped backup of the current configuration file in the configured backup directory.
Sourcepub async fn RollbackConfiguration(&self) -> Result<PathBuf>
pub async fn RollbackConfiguration(&self) -> Result<PathBuf>
Rollback configuration from the most recent backup
§Returns
Returns the path to the backup file that was restored
Sourcefn GetConfigPath(&self) -> Result<PathBuf>
fn GetConfigPath(&self) -> Result<PathBuf>
Get the configuration file path
Returns the configured path or the default path
Sourcefn GetDefaultConfigPath() -> Result<PathBuf>
fn GetDefaultConfigPath() -> Result<PathBuf>
Get default configuration file path
Returns the default configuration file path in the user’s config directory
Sourcepub fn GetProfileDefaults(profile: &str) -> AirConfiguration
pub fn GetProfileDefaults(profile: &str) -> AirConfiguration
Sourcepub fn ExpandPath(path: &str) -> Result<PathBuf>
pub fn ExpandPath(path: &str) -> Result<PathBuf>
Sourcepub fn ComputeHash(config: &AirConfiguration) -> Result<String>
pub fn ComputeHash(config: &AirConfiguration) -> Result<String>
Sourcepub fn ExportToJson(config: &AirConfiguration) -> Result<String>
pub fn ExportToJson(config: &AirConfiguration) -> Result<String>
Sourcepub fn ImportFromJson(json_str: &str) -> Result<AirConfiguration>
pub fn ImportFromJson(json_str: &str) -> Result<AirConfiguration>
Sourcepub fn GetEnvironmentMappings(&self) -> HashMap<String, String>
pub fn GetEnvironmentMappings(&self) -> HashMap<String, String>
Get environment variable mappings
Returns a mapping of configuration paths to environment variable names
Auto Trait Implementations§
impl Freeze for ConfigurationManager
impl RefUnwindSafe for ConfigurationManager
impl Send for ConfigurationManager
impl Sync for ConfigurationManager
impl Unpin for ConfigurationManager
impl UnwindSafe for ConfigurationManager
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].