rpkl

Crates.iorpkl
lib.rsrpkl
version0.3.4
sourcesrc
created_at2024-06-28 07:07:20.490913
updated_at2024-10-05 18:24:52.270037
descriptionBindings and codegen for Apple's Pkl configuration language
homepage
repositoryhttps://github.com/z-jxy/rpkl
max_upload_size
id1286495
size119,838
(z-jxy)

documentation

README

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()?;
Commit count: 35

cargo fmt