ini-rs
A rust crate to read an INI file into a structure. The data can be accessed directly if required.
Testing application can be found here
Crate.io entry here
Examples
Load an INI file
use Ini;
// Load foo.ini
let mut foo = match new ;
Read data from an INI file
match foo.get
Change data in the INI file, then save the change
foo.set;
match foo.save
Remove data from the INI file
foo.remove;
foo.remove_section;
Functions
new(location: String) -> Result<Ini, io::Error>
Load an INI file. If the file doesn't exist, create a blank Ini structure. Will return Err(io::Error) if the file provided is invalid.
set(section: &str, key: &str, value: &str) -> ()
Set, or create if it doesn't exist, a value in a section. It will also create the section if the section doesn't exist. This does not save the file.
get(section: &str, key: &str) -> Option
Get the key from the provided section. If it doesn't exist, returns None.
remove(section: &str, key: &str) -> ()
Remove a key from a section. Will not error if it doesn't exist. This does not save the file.
remove_section(section: &str) -> ()
Remove a section, will remove all keys from the section. Will not error if it doesn't exist. This does not save the file.
Save() -> Result<usize, io::Error>
Saves the changes to the file. Will not keep any comments present in the file. Ok(usize) contains the new size of the file.