Skip to main content

TomlValueSetExt

Trait TomlValueSetExt 

Source
pub trait TomlValueSetExt {
    // Required method
    fn set_with_seperator(
        &mut self,
        query: &str,
        sep: char,
        value: Value,
    ) -> Result<Option<Value>>;

    // Provided method
    fn set(&mut self, query: &str, value: Value) -> Result<Option<Value>> { ... }
}
Expand description

The Toml Set extensions

Required Methods§

Source

fn set_with_seperator( &mut self, query: &str, sep: char, value: Value, ) -> Result<Option<Value>>

Extension function for setting a value in the current toml::Value document using a custom seperator

§Semantics

The function never creates intermediate data structures (Tables or Arrays) in the document.

§Return value
  • If the set operation worked correctly, Ok(None) is returned.
  • If the set operation replaced an existing value Ok(Some(old_value)) is returned
  • On failure, Err(e) is returned:
    • If the query is "a.b.c" but there is no table "b": error
    • If the query is "a.b.[0]" but “b" is not an array: error
    • If the query is "a.b.[3]" but the array at “b" has no index 3: error
    • etc.

Provided Methods§

Source

fn set(&mut self, query: &str, value: Value) -> Result<Option<Value>>

Extension function for setting a value from the current toml::Value document

See documentation of TomlValueSetExt::set_with_seperator

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl TomlValueSetExt for Value

Source§

fn set_with_seperator( &mut self, query: &str, sep: char, value: Value, ) -> Result<Option<Value>>

Implementors§