Skip to main content

ConfigContent

Trait ConfigContent 

Source
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§

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Source

fn contains_key(&self, key: &Key) -> bool

Check if a key exists.

Source

fn keys(&self) -> Vec<Key>

Get all keys at the root level.

Source

fn len(&self) -> usize

Get the number of elements at the root level.

Source

fn is_empty(&self) -> bool

Check if the configuration is empty.

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.

Implementors§