iii

Crates.ioiii
lib.rsiii
version1.0.4
sourcesrc
created_at2023-01-31 03:13:11.112198
updated_at2023-08-29 07:05:23.687985
descriptionSimple configuration library,Easier than .ini
homepage
repositoryhttps://gitee.com/w-8/iii
max_upload_size
id772324
size11,835
(MDZZDYXCMDZZDYXC)

documentation

README

iii

Introduce

Simple configuration library,Easier than .ini

Config file format

default.iii
c1 = value
#2222
c2 = 233
c3 = ccc3
c5 = 5c
Create new config file
let mut cc = iii::BufData::new();
cc.chgvalue("c1", "value");
cc.chgvalue("c2", 666);
cc.chgvalue("c3", "value3");
if let Ok(_) = cc.save(None){
    println!("file write success")
};

Read config file and save

if let Ok(mut cc) = iii::BufData::loadfromiii("default.iii"){
    cc.chgvalue("c3", "ccc3");
    cc.chgvalue("c5", "5c");
    if let Ok(_) = cc.save(None){
        println!("file write success")
    };
};

Read value by key

if let Ok(cc) = iii::BufData::loadfromiii("default.iii"){
    if let Some(v) = cc.getvalue::<String>("c2"){
        println!("K:{},V:{}","c2",v);
    }
    if let Some(v) = cc.getvalue::<String>("c5"){
        println!("K:{},V:{}","c5",v);
    }
};

Save config file

let mut cc = iii::BufData::new();
cc.chgvalue("c1", "value");
if let Ok(_) = cc.save(None){
    println!("file write success")
};
if let Ok(_) = cc.save(Some("file1.iii")){
    println!("file write success")
};

Other

If you want to read the numeric type,exp like:

let mut cc = iii::BufData::new();
cc.chgvalue("c2", "33");
cc.chgvalue("c4", true);
if let Ok(number) = cc.getvalue::<u32>("c2"){
    println!("number:");
    assert!(33==number);
};
if let Ok(var) = cc.getvalue::<bool>("c4"){
    println!("bool:");
    assert!(true==var);
}
Commit count: 0

cargo fmt