| Crates.io | rpkl-jdx |
| lib.rs | rpkl-jdx |
| version | 0.4.0 |
| created_at | 2025-02-15 23:27:56.985697+00 |
| updated_at | 2025-02-15 23:27:56.985697+00 |
| description | Bindings and codegen for Apple's Pkl configuration language |
| homepage | |
| repository | https://github.com/z-jxy/rpkl |
| max_upload_size | |
| id | 1557185 |
| size | 172,395 |
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
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::from_config("./config.pkl")?;
You can pass options to the evaluator, such as properties, by using [from_config_with_options].
username = read("prop:username")
password = read("prop:password")
let options = EvaluatorOptions::default()
.properties([("username", "root"), ("password", "password123")]);
let config: Config = rpkl::from_config_with_options("./config.pkl", Some(options))?;
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()?;