pub struct Section { /* private fields */ }Expand description
A section containing key-value pairs and nested subsections.
Sections form a hierarchical structure similar to directories, where each section can contain both values and other sections.
Implementations§
Source§impl Section
impl Section
Sourcepub fn get_or_create_value(&mut self, key: &str) -> &mut Value
pub fn get_or_create_value(&mut self, key: &str) -> &mut Value
Get a value by key, creating it if it doesn’t exist.
This is similar to the C++ operator[] behavior.
Sourcepub fn get_value_mut(&mut self, key: &str) -> Result<&mut Value>
pub fn get_value_mut(&mut self, key: &str) -> Result<&mut Value>
Get a mutable value by key.
Sourcepub fn set_value(&mut self, key: impl Into<String>, value: impl Into<Value>)
pub fn set_value(&mut self, key: impl Into<String>, value: impl Into<Value>)
Set a value for a key.
Sourcepub fn remove_value(&mut self, key: &str) -> Option<Value>
pub fn remove_value(&mut self, key: &str) -> Option<Value>
Remove a value by key.
Sourcepub fn get_section(&self, name: &str) -> Result<&Section>
pub fn get_section(&self, name: &str) -> Result<&Section>
Get a subsection by name.
Sourcepub fn section(&mut self, name: &str) -> &mut Section
pub fn section(&mut self, name: &str) -> &mut Section
Get a subsection by name, creating it if it doesn’t exist.
Sourcepub fn get_section_mut(&mut self, name: &str) -> Result<&mut Section>
pub fn get_section_mut(&mut self, name: &str) -> Result<&mut Section>
Get a mutable subsection by name.
Sourcepub fn has_section(&self, name: &str) -> bool
pub fn has_section(&self, name: &str) -> bool
Check if a subsection exists.
Sourcepub fn remove_section(&mut self, name: &str) -> Option<Section>
pub fn remove_section(&mut self, name: &str) -> Option<Section>
Remove a subsection by name.
Sourcepub fn values(&self) -> impl Iterator<Item = (&String, &Value)>
pub fn values(&self) -> impl Iterator<Item = (&String, &Value)>
Iterate over all values in this section.
Sourcepub fn values_mut(&mut self) -> impl Iterator<Item = (&String, &mut Value)>
pub fn values_mut(&mut self) -> impl Iterator<Item = (&String, &mut Value)>
Iterate over all values in this section (mutable).
Sourcepub fn sections(&self) -> impl Iterator<Item = (&String, &Section)>
pub fn sections(&self) -> impl Iterator<Item = (&String, &Section)>
Iterate over all subsections in this section.
Sourcepub fn sections_mut(&mut self) -> impl Iterator<Item = (&String, &mut Section)>
pub fn sections_mut(&mut self) -> impl Iterator<Item = (&String, &mut Section)>
Iterate over all subsections in this section (mutable).
Sourcepub fn value_count(&self) -> usize
pub fn value_count(&self) -> usize
Get the number of values in this section.
Sourcepub fn section_count(&self) -> usize
pub fn section_count(&self) -> usize
Get the number of subsections in this section.
Sourcepub fn value_keys(&self) -> impl Iterator<Item = &String>
pub fn value_keys(&self) -> impl Iterator<Item = &String>
Get all value keys.
Sourcepub fn section_names(&self) -> impl Iterator<Item = &String>
pub fn section_names(&self) -> impl Iterator<Item = &String>
Get all section names.