claude_code_toolkit/traits/
config.rs1use crate::error::Result;
4use crate::types::Config;
5use async_trait::async_trait;
6use std::any::Any;
7use std::path::Path;
8
9#[async_trait]
11pub trait ConfigProvider: Send + Sync {
12 async fn load_config(&self) -> Result<Config>;
14
15 async fn save_config(&self, config: &Config) -> Result<()>;
17
18 async fn validate_config(&self, config: &Config) -> Result<()>;
20
21 async fn config_exists(&self) -> Result<bool>;
23
24 fn config_path(&self) -> Option<&Path>;
26
27 fn as_any(&self) -> &dyn Any;
29}
30
31#[async_trait]
33pub trait ConfigManager: Send + Sync {
34 async fn initialize(&self) -> Result<Config>;
36
37 async fn load(&self) -> Result<Config>;
39
40 async fn save(&self, config: &Config) -> Result<()>;
42
43 async fn update_section<T>(&self, section: &str, data: T) -> Result<()> where T: Send + Sync;
45
46 async fn backup(&self) -> Result<String>;
48
49 async fn restore(&self, backup_id: &str) -> Result<()>;
51}