Uclicious

Uclicious is a wrapper around Universal Configuration Library (UCL) parser with a lot of sugar.

Uclicious is built on top of libucl. It is much more complex than json or TOML, so I recommend reading documentaiton about it. Library provides safe, but raw API to that library: ```rust use uclicious::*; let mut parser = Parser::default(); let input = r#" teststring = "no scope" afloat = 3.14 aninteger = 69420 isitgood = yes buffersize = 1KB "#; parser.addchunkfull(input, Priority::default(), DEFAULTDUPLICATESTRATEGY).unwrap(); let result = parser.get_object().unwrap();

let lookupresult = result.lookup("teststring").unwrap().asstring().unwrap(); asserteq!(lookupresult.asstr(), "no scope");

let lookupresult = result.lookup("afloat").unwrap().asf64().unwrap(); asserteq!(lookup_result, 3.14f64);

let lookupresult = result.lookup("aninteger").unwrap().asi64().unwrap(); asserteq!(lookup_result, 69420i64);

let lookupresult = result.lookup("isitgood").unwrap().asbool().unwrap(); asserteq!(lookupresult, true);

let lookupresult = result.lookup("buffersize").unwrap().asi64().unwrap(); asserteq!(lookup_result, 1024); ```

In order to get around rust rules library implemets its own trait FromObject for some basic types: ```rust use uclicious::*; let mut parser = Parser::default(); let input = r#" teststring = "no scope" afloat = 3.14 aninteger = 69420 isitgood = yes buffersize = 1KB "#; parser.addchunkfull(input, Priority::default(), DEFAULTDUPLICATESTRATEGY).unwrap(); let result = parser.get_object().unwrap();

let lookupresult = result.lookup("isitgood").unwrap(); let maybe: Option = FromObject::tryfrom(lookupresult).unwrap(); asserteq!(Some(true), maybe); ```

Automatic Derive

On top of "raw" interface to libUCL, Uclicious provides an easy way to derive constructor for strucs: ```rust use uclicious::*; use std::path::PathBuf; use std::net::SocketAddr; use std::collections::HashMap;

[derive(Debug,Uclicious)]

[ucl(var(name = "test", value = "works"))]

struct Connection { #[ucl(default)] enabled: bool, host: String, #[ucl(default = "420")] port: i64, buffer: u64, #[ucl(path = "type")] kind: String, locations: Vec, addr: SocketAddr, extra: Extra, #[ucl(path = "subsection.host")] hosts: Vec, #[ucl(default)] option: Option, gates: HashMap, }

[derive(Debug,Uclicious)]

[ucl(skip_builder)]

struct Extra { enabled: bool } let mut builder = Connection::builder().unwrap();

let input = r#" enabled = yes host = "some.fake.url" buffer = 1mb type = $test locations = "/etc/" addr = "127.0.0.1:80" extra = { enabled = on } subsection { host = [host1, host2] } gates { feature1 = on feature2 = off feature_3 = on }"#;

builder.addchunkfull(input, Priority::default(), DEFAULTDUPLICATESTRATEGY).unwrap(); let connection: Connection = builder.build().unwrap(); ```

If you choose to derive builder then ::builder() method will be added to target struct.

Supported attributes (#[ucl(..)])

Structure level

Field level

Additional notes

Contributing

PRs, feature requests, bug reports are welcome. I won't be adding CoC — be civilized.

Goals

Not Goals

Special thanks

LICENSE

BSD-2-Clause.