pub trait ConfigContent:
Sized
+ Send
+ Sync
+ FromStr<Err = ConfigError>
+ Display {
// Required methods
fn select(&self, key: &Key) -> ConfigResult<Value>;
fn insert(&mut self, key: &Key, value: &Value) -> ConfigResult<()>;
fn update(&mut self, key: &Key, value: &Value) -> ConfigResult<()>;
fn delete(&mut self, key: &Key) -> ConfigResult<()>;
fn upsert(&mut self, key: &Key, value: &Value) -> ConfigResult<()>;
// Provided methods
fn contains_key(&self, key: &Key) -> bool { ... }
fn keys(&self) -> Vec<Key> { ... }
fn len(&self) -> usize { ... }
fn is_empty(&self) -> bool { ... }
}Expand description
Unified trait for configuration content operations.
Required Methods§
Sourcefn select(&self, key: &Key) -> ConfigResult<Value>
fn select(&self, key: &Key) -> ConfigResult<Value>
Select a value by key path.
§Errors
Returns ConfigError::KeyNotFound if the key does not exist.
Returns ConfigError::InvalidKey if the key format is invalid.
Sourcefn insert(&mut self, key: &Key, value: &Value) -> ConfigResult<()>
fn insert(&mut self, key: &Key, value: &Value) -> ConfigResult<()>
Insert a new value at the specified key path.
§Errors
Returns ConfigError::KeyAlreadyExists if the key already exists.
Returns ConfigError::InvalidKey if the key format is invalid.
Sourcefn update(&mut self, key: &Key, value: &Value) -> ConfigResult<()>
fn update(&mut self, key: &Key, value: &Value) -> ConfigResult<()>
Update an existing value at the specified key path.
§Errors
Returns ConfigError::KeyDoesNotExist if the key does not exist.
Returns ConfigError::InvalidKey if the key format is invalid.
Sourcefn delete(&mut self, key: &Key) -> ConfigResult<()>
fn delete(&mut self, key: &Key) -> ConfigResult<()>
Delete a value at the specified key path.
§Errors
Returns ConfigError::KeyNotFound if the key does not exist.
Returns ConfigError::DeleteError if trying to delete the root.
Sourcefn upsert(&mut self, key: &Key, value: &Value) -> ConfigResult<()>
fn upsert(&mut self, key: &Key, value: &Value) -> ConfigResult<()>
Upsert (insert or update) a value at the specified key path.
§Errors
Returns ConfigError::InvalidKey if the key format is invalid.
Provided Methods§
Sourcefn contains_key(&self, key: &Key) -> bool
fn contains_key(&self, key: &Key) -> bool
Check if a key exists.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.