pub struct Config { /* private fields */ }Expand description
Thread-safe configuration store.
Provides flat key-value storage with type-safe accessors.
Keys use dot notation for logical grouping: editor.theme, plugin.lsp.timeout
§Thread Safety
All operations are thread-safe via internal RwLock.
Multiple readers allowed, single writer for mutations.
§Example
use reovim_kernel::api::v1::{Config, ConfigValue};
let config = Config::new();
// Set values
config.set_str("editor.theme", "dark");
config.set_int("editor.tabwidth", 4);
// Get values
assert_eq!(config.get_str("editor.theme"), Some("dark".to_string()));
assert_eq!(config.get_int("editor.tabwidth"), Some(4));Implementations§
Source§impl Config
impl Config
Sourcepub fn get(&self, key: &str) -> Option<ConfigValue>
pub fn get(&self, key: &str) -> Option<ConfigValue>
Get a configuration value by key.
Keys use dot notation: editor.theme, plugin.lsp.timeout
Sourcepub fn get_or(&self, key: &str, default: ConfigValue) -> ConfigValue
pub fn get_or(&self, key: &str, default: ConfigValue) -> ConfigValue
Get a value with a default fallback.
Sourcepub fn get_bool_or(&self, key: &str, default: bool) -> bool
pub fn get_bool_or(&self, key: &str, default: bool) -> bool
Get a boolean with a default.
Sourcepub fn get_int_or(&self, key: &str, default: i64) -> i64
pub fn get_int_or(&self, key: &str, default: i64) -> i64
Get an integer with a default.
Sourcepub fn get_str_or(&self, key: &str, default: &str) -> String
pub fn get_str_or(&self, key: &str, default: &str) -> String
Get a string with a default.
Sourcepub fn set(&self, key: &str, value: ConfigValue)
pub fn set(&self, key: &str, value: ConfigValue)
Set a configuration value.
Keys use dot notation. Previous value is overwritten.
Sourcepub fn remove(&self, key: &str) -> Option<ConfigValue>
pub fn remove(&self, key: &str) -> Option<ConfigValue>
Remove a configuration key.
Returns the removed value if it existed.
Sourcepub fn keys_with_prefix(&self, prefix: &str) -> Vec<String>
pub fn keys_with_prefix(&self, prefix: &str) -> Vec<String>
Get all keys matching a prefix.
Sourcepub fn merge(&self, other: &Self)
pub fn merge(&self, other: &Self)
Merge another config into this one.
Values from other overwrite values in self.
Sourcepub fn to_map(&self) -> HashMap<String, ConfigValue>
pub fn to_map(&self) -> HashMap<String, ConfigValue>
Export all data as a HashMap.
Sourcepub fn from_map(&self, map: HashMap<String, ConfigValue>)
pub fn from_map(&self, map: HashMap<String, ConfigValue>)
Import data from a HashMap.