restflow_core/services/
config.rs

1use crate::{AppCore, storage::config::SystemConfig};
2use anyhow::{Context, Result};
3use std::sync::Arc;
4
5// Get complete system configuration
6pub async fn get_config(core: &Arc<AppCore>) -> Result<SystemConfig> {
7    match core
8        .storage
9        .config
10        .get_config()
11        .context("Failed to get config")?
12    {
13        Some(config) => Ok(config),
14        None => Ok(SystemConfig::default()),
15    }
16}
17
18// Update system configuration with validation
19pub async fn update_config(core: &Arc<AppCore>, config: SystemConfig) -> Result<()> {
20    // Validate configuration before updating
21    config.validate().context("Invalid configuration")?;
22
23    // Update configuration
24    core.storage
25        .config
26        .update_config(config)
27        .context("Failed to update config")
28}