pub struct Ini {
pub config_map: BTreeMap<String, BTreeMap<String, String>>,
pub config_file: String,
}Expand description
Load INI files into a structured BTreeMap, then edit them. Can also create new INI files. You can access the data directly via config_map, or use the provided functions. This only works on Windows and Linux
Fields§
§config_map: BTreeMap<String, BTreeMap<String, String>>§config_file: StringImplementations§
Source§impl Ini
impl Ini
Sourcepub fn new(location: String) -> Result<Ini, Error>
pub fn new(location: String) -> Result<Ini, Error>
Load in an INI file and return its structure. If the file doesn’t exist, then returns empty structure.
Sourcepub fn from_string(str: String) -> Result<Ini, Error>
pub fn from_string(str: String) -> Result<Ini, Error>
Create ini structure from a string. Does not set the config_file so save doesn’t work unless set manually.
Sourcepub fn to_string(&self) -> Result<String, Error>
pub fn to_string(&self) -> Result<String, Error>
Dump out the INI file to a string, returns blank string if no data is present
Sourcepub fn save(&self) -> Result<usize, Error>
pub fn save(&self) -> Result<usize, Error>
Save an INI file after being edited. Only functions correctly on Windows and Linux. Ok will contain the size in bytes of the file after writing. All comments in the INI file will be lost by doing this.
Sourcepub fn set(&mut self, section: &str, key: &str, value: &str)
pub fn set(&mut self, section: &str, key: &str, value: &str)
Set a value in the INI file. If the section doesn’t exist, it will be created. If the key doesn’t exist, it will be created. This will not save the file.
Sourcepub fn remove(&mut self, section: &str, key: &str)
pub fn remove(&mut self, section: &str, key: &str)
Remove a key from the INI file. If the section doesn’t exist, it will be created. If the key doesn’t exist, it will be created. This will not save the file.
Sourcepub fn remove_section(&mut self, section: &str)
pub fn remove_section(&mut self, section: &str)
Remove a section from the INI file. This will not save the file.