pub struct Mapping(/* private fields */);Expand description
A YAML mapping (key-value pairs)
Implementations§
Source§impl Mapping
impl Mapping
Sourcepub fn set(
&mut self,
key: impl Into<ScalarValue>,
value: impl Into<ScalarValue>,
)
pub fn set( &mut self, key: impl Into<ScalarValue>, value: impl Into<ScalarValue>, )
Set a key-value pair with a scalar value, replacing if exists or adding if new This method automatically escapes the key and value as needed.
Sourcepub fn set_value(&mut self, key: impl Into<ScalarValue>, value: YamlValue)
pub fn set_value(&mut self, key: impl Into<ScalarValue>, value: YamlValue)
Set a key-value pair with any YAML value type (scalar, sequence, mapping)
Sourcepub fn set_raw(&mut self, key: &str, value: &str)
pub fn set_raw(&mut self, key: &str, value: &str)
Set a key-value pair, replacing if exists or adding if new This is the low-level method that doesn’t escape values.
Sourcepub fn rename_key(
&mut self,
old_key: &str,
new_key: impl Into<ScalarValue>,
) -> bool
pub fn rename_key( &mut self, old_key: &str, new_key: impl Into<ScalarValue>, ) -> bool
Rename a key while preserving its value and formatting, with proper escaping
Sourcepub fn rename_key_raw(&mut self, old_key: &str, new_key: &str) -> bool
pub fn rename_key_raw(&mut self, old_key: &str, new_key: &str) -> bool
Rename a key while preserving its value and formatting This is the low-level method that doesn’t escape the new key.
Sourcepub fn set_path(&mut self, path: &str, value: impl Into<ScalarValue>)
pub fn set_path(&mut self, path: &str, value: impl Into<ScalarValue>)
Set a value at a nested path with proper escaping (e.g., “db.host” to set db: {host: value})
Sourcepub fn set_path_raw(&mut self, path: &str, value: &str)
pub fn set_path_raw(&mut self, path: &str, value: &str)
Set a value at a nested path (e.g., “db.host” to set db: {host: value}) This is the low-level method that doesn’t escape values.