pub struct Config {
pub default_server: Option<String>,
pub servers: HashMap<String, ServerConfig>,
pub preferences: Preferences,
}Expand description
Top-level configuration
Fields§
§default_server: Option<String>Default server to use when none specified
servers: HashMap<String, ServerConfig>Named server configurations
preferences: PreferencesUser preferences
Implementations§
Source§impl Config
impl Config
Sourcepub fn config_dir() -> Result<PathBuf, CoreError>
pub fn config_dir() -> Result<PathBuf, CoreError>
Get the default configuration directory
Sourcepub fn default_config_path() -> Result<PathBuf, CoreError>
pub fn default_config_path() -> Result<PathBuf, CoreError>
Get the default configuration file path
Sourcepub fn load_from_file(path: &Path) -> Result<Self, CoreError>
pub fn load_from_file(path: &Path) -> Result<Self, CoreError>
Load configuration from a specific file
Sourcepub fn load_from_python_json(path: &Path) -> Result<Self, CoreError>
pub fn load_from_python_json(path: &Path) -> Result<Self, CoreError>
Load configuration from Python’s JSON format (for migration)
Sourcepub fn save_to_file(&self, path: &Path) -> Result<(), CoreError>
pub fn save_to_file(&self, path: &Path) -> Result<(), CoreError>
Save configuration to a specific file
Sourcepub fn add_server(&mut self, name: String, server: ServerConfig)
pub fn add_server(&mut self, name: String, server: ServerConfig)
Add or update a server configuration
Sourcepub fn get_server(&self, name: &str) -> Option<&ServerConfig>
pub fn get_server(&self, name: &str) -> Option<&ServerConfig>
Get a server configuration by name
Sourcepub fn get_default_server(&self) -> Option<(&String, &ServerConfig)>
pub fn get_default_server(&self) -> Option<(&String, &ServerConfig)>
Get the default server configuration
Sourcepub fn list_servers(&self) -> Vec<&String>
pub fn list_servers(&self) -> Vec<&String>
List all server names
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
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
Mutably borrows from an owned value. Read more