Crates.io | pretty_ini |
lib.rs | pretty_ini |
version | 0.1.7 |
source | src |
created_at | 2022-12-20 09:54:40.218412 |
updated_at | 2023-04-16 13:41:33.445357 |
description | Light library to read/write ini files |
homepage | |
repository | https://github.com/eVisualUser/pretty-ini |
max_upload_size | |
id | 742165 |
size | 19,952 |
Light library to read/write ini files.
[table_name]
key = value
use pretty_ini::{ini, ini_file};
fn main() {
let mut file = ini_file::IniFile::default();
file.set_path("demo.ini");
let mut ini = ini::Ini::default();
ini.load(&mut file).unwrap();
let var_iter = ini.get_ref_mut(ini::TABLE_NAME_ROOT, "iter").unwrap();
var_iter.set(var_iter.parse::<i32>().unwrap() + 1);
println!("All keys contained in: \"Next\"");
for key in ini
.get_all_keys_in_table("next")
.expect("No key found in Next")
{
println!("- {}", key);
}
file.save(&mut ini);
}
In the IniFile you can add some process using a ProcessAction.
Called before assigning the file content to the buffer.
let action = Some(Box::new(|buffer| {
// Do nothing
return buffer;
}));
ini_file.add_pre_process(action);
Called before saving the file.
let action = Some(Box::new(|buffer| {
// Do nothing
return buffer;
}));
ini_file.add_post_process(action);