Crate gostd_settings
source ·Expand description
gostd_settings is a library for reading and writing property files. gostd_settings can be saved in or loaded from the stream. Each key and its corresponding value in the attribute list is a string. It is thread safe: multiple threads can share a single gostd_ Settings object without external synchronization.
zh-cn
gostd_settings 是一个用于读写属性文件的库。gostd_settings可保存在流中或从流中加载。 属性列表中每个键及其对应值都是一个字符串。它是线程安全的:多个线程可以共享单个 gostd_settings 对象而无需进行外部同步。§Example
use gostd_settings::{Settings, builder};
let mut p = builder().file_type_properties().build();
p.set_property("HttpPort", "8081");
p.set_property(
"MongoServer",
"mongodb://10.11.1.5,10.11.1.6,10.11.1.7/?replicaSet=mytest",
);
p.set_property_slice(
"LogLevel",
["Debug", "Info", "Warn"].iter().map(|s| s.to_string()).collect(),
);
match p.store_to_file("config.properties") {
Ok(()) => println!("store to file app.conf success"),
Err(err) => println!("store to file app.conf failed: {}", err),
}
Run§Output
$ cat config.properties
HttpPort = 8081
LogLevel = Debug,Info,Warn
MongoServer = mongodb://10.11.1.5,10.11.1.6,10.11.1.7/?replicaSet=mytest
Structs§
Traits§
- Summary of read and write methods for management configuration files