pklrust
Pronounced "Pickles" -- as in the food.
Rust bindings for Apple Pkl — a configuration-as-code language.
This library communicates with pkl server via MessagePack IPC, providing a native Rust interface to evaluate Pkl modules and deserialize results into Rust types through serde.
Crates
| Crate | Description |
|---|---|
pklrust |
Core library — IPC protocol, pkl-binary decoder, serde Deserializer |
pklrust-derive |
#[derive(FromPkl)] and pkl! proc-macros |
pklrust-codegen |
CLI tool (pkl-gen-rust) to generate Rust structs from .pkl schemas |
Quick Start
[]
= "0.2"
= { = "1", = ["derive"] }
use ;
use Deserialize;
pkl! macro
Write PKL configuration as tokens directly in Rust — no string literals needed:
use pkl;
The macro supports most PKL constructs:
let value = pkl! ?;
Limitations: PKL raw strings (
#"..."#), string interpolation (\(expr)), and multi-line strings ("""...""") are not supported in the macro. UseModuleSource::text(...)with a raw string literal for these cases.
You can also evaluate .pkl files directly:
let source = file;
Or evaluate a specific expression:
let value = manager.evaluate_expression?;
Prerequisites
The pkl CLI must be installed and available on your PATH.
# macOS
# or download from https://pkl-lang.org
Code Generation
Generate Rust types from Pkl schema files:
License
MIT