Instructions¶
These steps assume a Linux machine and Rust 1.70 or newer. The Cargo package
is gld-kiln. The import name is kiln. The generator binary is
gld-kilngen-rust.
Install¶
use kiln::{decode, encode, Schema, Value} then resolves the dynamic codec.
Build this repository¶
| Script | What it runs |
|---|---|
bash scripts/run-tests.sh |
cargo test and cargo clippy --all-targets -- -D warnings. |
bash scripts/generate.sh |
Writes tests/generated from testdata/schema. |
bash scripts/check-generated.sh |
Regenerates into a temp directory and diffs. |
bash scripts/run-microbench.sh |
Encodes and decodes a 1024-struct batch and one 1024-element f32 tensor. |
Decode and encode¶
use kiln::{decode, encode, Schema, Value};
let schema = Schema::struct_fields([("x", Schema::I32), ("y", Schema::I32)]);
let value = Value::Struct(vec![Value::I32(3), Value::I32(-4)]);
let raw = encode(&schema, &value)?;
let back = decode(&schema, &raw)?;
DecodeOpts raises the cap or selects a trusted reader. encode_framed writes
a KLN0 frame whose hash is type_hash.
Generate Rust¶
The generator writes one .rs file per schema title. Compile that file in a
crate that depends on gld-kiln. The generated module imports kiln.
Document the package¶
The site is Material for MkDocs with an indigo primary color and a teal accent.