scfg-rs
A rust library for parsing scfg files. Scfg is a simple line oriented
configuration file format. Every line may contain at most one directive per
line. A directive consists of a name, followed by optional parameters
separated by whitespace followed by an optional child block, delimited by
{
and }
. Whitespace at the beginning of lines is insignificant. Lines
beginning with #
are comments and are ignored.
Examples
use Scfg;
// an scfg document
static SCFG_DOC: &str = r#"train "Shinkansen" {
model "E5" {
max-speed 320km/h
weight 453.5t
lines-served "Tōhoku" "Hokkaido"
}
model "E7" {
max-speed 275km/h
weight 540t
lines-served "Hokuriku" "Jōetsu"
}
}"#;
let doc = SCFG_DOC..expect;
// the above document can also be created with this builder style api
let mut scfg = new;
let train = scfg
.add
.append_param
.get_or_create_child;
let e5 = train.add.append_param.get_or_create_child;
e5.add.append_param;
e5.add.append_param;
e5.add
.append_param
.append_param;
let e7 = train.add.append_param.get_or_create_child;
e7.add.append_param;
e7.add.append_param;
e7.add
.append_param
.append_param;
assert_eq!;
Contributing
Please send patches to the mailing list
LICENSE
MIT OR Apache-2.0