pub struct Ini { /* private fields */ }Implementations§
Source§impl Ini
impl Ini
Sourcepub fn set_section(&mut self, section_name: &str)
pub fn set_section(&mut self, section_name: &str)
Ensure a named section exists in the INI document.
If the section does not exist, it will be created. The general section (None) cannot be created explicitly.
§Arguments
section_name- The name of the section to ensure exists.
Sourcepub fn set_property<T: ToString>(
&mut self,
section_name: Option<&str>,
key: &str,
value: Option<T>,
) -> Result<(), ConfigError>
pub fn set_property<T: ToString>( &mut self, section_name: Option<&str>, key: &str, value: Option<T>, ) -> Result<(), ConfigError>
Set a property value in a section.
The section must already exist. If the property does not exist, it will be created; if it exists, it will be overwritten.
If value is Some, sets the key-value pair; if None, sets only the key name (no value).
§Arguments
section_name- The section name (None for general section).key- The property key.value- The property value (optional).
§Errors
Returns ConfigError::SectionNotFound if the section does not exist.
Sourcepub fn set_section_doc(
&mut self,
section_name: Option<&str>,
doc_texts: Vec<String>,
) -> Result<(), ConfigError>
pub fn set_section_doc( &mut self, section_name: Option<&str>, doc_texts: Vec<String>, ) -> Result<(), ConfigError>
Sourcepub fn set_property_doc(
&mut self,
section_name: Option<&str>,
key: &str,
doc_texts: Vec<String>,
) -> Result<(), ConfigError>
pub fn set_property_doc( &mut self, section_name: Option<&str>, key: &str, doc_texts: Vec<String>, ) -> Result<(), ConfigError>
Set documentation comments for a property.
§Arguments
section_name- The section name (None for general section).key- The property key.doc_texts- Documentation lines to associate with the property.
§Errors
Returns ConfigError::SectionNotFound if the section does not exist, or ConfigError::PropertyNotFound if the property does not exist.
Sourcepub fn get_value<T: FromStr>(
&self,
section_name: Option<&str>,
key: &str,
) -> Result<Option<T>, T::Err>
pub fn get_value<T: FromStr>( &self, section_name: Option<&str>, key: &str, ) -> Result<Option<T>, T::Err>
Get the value of the specified section and key, parse to the specified type via FromStr
Sourcepub fn get_string(&self, section_name: Option<&str>, key: &str) -> Option<&str>
pub fn get_string(&self, section_name: Option<&str>, key: &str) -> Option<&str>
Get the raw string value of the specified section and key
Sourcepub fn has_property(&self, section_name: Option<&str>, key: &str) -> bool
pub fn has_property(&self, section_name: Option<&str>, key: &str) -> bool
Check if the specified property exists
Sourcepub fn remove_property(&mut self, section_name: Option<&str>, key: &str) -> bool
pub fn remove_property(&mut self, section_name: Option<&str>, key: &str) -> bool
Remove the specified property
Sourcepub fn remove_section(&mut self, section_name: Option<&str>) -> bool
pub fn remove_section(&mut self, section_name: Option<&str>) -> bool
Remove the specified section
Sourcepub fn section(&self, name: Option<&str>) -> Option<&SectionDocument>
pub fn section(&self, name: Option<&str>) -> Option<&SectionDocument>
Get the specified section properties
Sourcepub fn section_mut(
&mut self,
name: Option<&str>,
) -> Option<&mut SectionDocument>
pub fn section_mut( &mut self, name: Option<&str>, ) -> Option<&mut SectionDocument>
Get a mutable reference to the specified section properties