#pkl #apple #configuration-language #codegen #derive-deserialize

rpkl

Bindings and codegen for Apple's Pkl configuration language

4 releases (2 breaking)

0.3.1 Aug 5, 2024
0.3.0 Jul 23, 2024
0.2.0 Jul 18, 2024
0.1.0 Jun 28, 2024

#238 in Configuration

Download history 108/week @ 2024-06-24 14/week @ 2024-07-01 99/week @ 2024-07-15 123/week @ 2024-07-22 23/week @ 2024-07-29 168/week @ 2024-08-05 22/week @ 2024-08-12 16/week @ 2024-08-19 33/week @ 2024-08-26

240 downloads per month
Used in 2 crates

MIT license

87KB
2.5K SLoC

rpkl

crates.io docs.rs

Language bindings to Pkl for Rust.

Requires the pkl binary to be available on your path. You can install pkl for your os using the steps from their docs: https://pkl-lang.org/main/current/pkl-cli/index.html#installation

Usage

ip = "127.0.0.1"

database {
    username = "admin"
    password = "secret"
}
#[derive(Deserialize)]
struct Config {
    ip: String,
    database: Database,
}

#[derive(Deserialize)]
struct Database {
    username: String,
    password: String,
}

let config: Config = rpkl::value_from_config("./config.pkl")?;

Codegen

Mostly works, but still a WIP. If you want to try it out, you can enable the codegen feature.

let mut evaluator = rpkl::evaluator::Evaluator::new()?;
let pkl_mod = evaluator.evaluate_module(PathBuf::from("./config.pkl"))?;
pkl_mod.codegen()?;

Dependencies

~0.9–7.5MB
~55K SLoC