core:kiln
Kiln stdlib entry point.
Import the user-facing Kiln types via use { ... } from "core:kiln". This
facade re-exports the WIT-generated submodules under lib/core/kiln/ and
adds the Wado-only Request<T> wrapper that generator authors write
against.
See WEP 2026-04-12 (Kiln) §"The generator contract" and §"Options are a typed argument in each generator's own world".
Functions
pub fn read_all(content: Stream<u8>) -> ByteList
Read an input file's content to the end. A generator that needs the whole
file calls this; one that needs a prefix reads content itself and drops
it early.
pub fn read_text(content: Stream<u8>) -> Result<String, Utf8Error>
Read an input file's content to the end as text, decoding as it goes so no
second copy of the file exists. Err is a malformed input, not a bug.
pub fn package_of(module: &String) -> Option<String>
The package spec in module, a Request's module: the part before any
version or file path, which is what the consumer's [dependencies] names
the generator's package under. Generated code imports the generator's
runtime library by it. None where the use site named the generator by a
path, which names no package.
Structs
pub struct KilnLogSink {}
The core:log handler a generator runs under. Its host reports each stdout
line as an info and each stderr line as a warning, so the compiler installs
this one around generate's body, which writes each event to the stream of
its level.
impl Log for KilnLogSink
fn enabled(&self, level: Level) -> bool
fn event(&mut self, event: Event)
pub struct NoOptions {}
The options type of a generator that takes no configuration. It is the
default type argument of Request, so a generator with no Options
struct writes fn generate(req: Request) and never mentions options.
Its CBOR wire form is the empty map, which decodes back into NoOptions.
pub affine struct Request<T = NoOptions>
The typed request a Kiln generator receives. Generator authors write
export fn generate(req: Request<Options>) -> Result<Response, Error>
(or Request for a no-options generator).
Request<T> is Wado-only sugar and never crosses the WIT boundary as a
single record: a generic cannot be expressed in a fixed WIT world (that is
why generators do not share one world). The compiler rewrites
fn generate(req: Request<T>) into flat, typed parameters
(primary: InputFile, inputs: List<InputFile>, module: String, options: T) in the
generator's own synthesized world, then rebinds them into a Request<T>
value so the author's body sees req unchanged. options crosses as a
typed WIT argument, not a serialized blob. The #[compiler_item("kiln_request")]
attribute is that rewrite's lookup anchor. T defaults to NoOptions, so
a generator that takes no options writes fn generate(req: Request).
See WEP 2026-04-12 §"Options are a typed argument in each generator's own world".
primary: InputFile
inputs: List<InputFile>
module: String
How the use site named this generator: its module: specifier as
written, or for a path, that path from the package root.
options: T
pub affine struct InputFile
One schema file the compiler opened for the generator. The set of files is fixed by the invocation declaration; the content arrives as a stream so a generator reads only as far as it needs.
path: String
content: Stream<u8>
type: Option<String>
The type the use site gave the file, which says how the
generator reads it: the type beside generator for the primary
input, an input's own for the rest. none where it gave none.
pub struct OutputFile
One generated Wado file. path is relative to the invocation's
output directory (defaults to build/kiln/<invocation-name>/).
Exactly one output file must be the entry module; supplementary
files are referenced from the entry via ordinary Wado use.
