Expand description
IR v2 package to Rust source plus an extern-C header (ADR-0004 section 7, ADR-0007 decision 13).
The full E1.12 backend over the typl surface. Each declaration in a
v2::Package is realized twice: once as idiomatic Rust (the language
layer of typl reference Appendix D — every integer is i64, every float is
f64) and once, where the C ABI admits it, as an entry in a companion C
header. Named scalar types become #[repr(transparent)] newtypes so unit
safety survives into generated code (typl reference §5.7); composites map to
structs, enums, and Rust enum unions.
Rust source is built as a proc_macro2::TokenStream with quote and
formatted with prettyplease, never by shelling out to rustfmt.
Default derivation follows the leaf-recursion rule: an impl Default is
emitted for a type only when every field it transitively contains is
derivable. The IR InitValue.derivable flag on a composite-typed field is a
one-level flag, so same-package composite references are re-checked by
recursion rather than trusted (see the defaults module).
Derive eligibility uses the same recursion over the transitive closure, in
the derives module: Debug, Clone and PartialEq on every generated
type, Copy, Eq, Hash and the ordering pair where the closure permits,
and Default never, because it comes from the typl init value instead.
Structs§
- Generate
Error - A failure to generate code from a package.
- Generated
- The generated artifact for one package: Rust source.
Enums§
- Wire
Encoding - The payload encoding a generated package’s face encodes and verifies over (design note D-11; ADR-0020 decision 1 names the three encodings).
Functions§
- generate
- Generates the Rust source for
package: the domain types only. The only runtime paths in its output are the::ridl_rt::payload::Violationand::ridl_rt::payload::Rulethat a named scalar’s constructor (typl value objects, Task 3) and an enum’s or enum set’sTryFrom<i64>(Task 5) name; it emits no interaction face. - generate_
face - Generates the Rust source for
package: the domain typesgenerateemits, plus the interaction-face descriptors over theridl-rtruntime crate (Lane M stage M3). - generate_
face_ with generate_facewith the package’s wire encoding stated rather than defaulted (design note D-11 ofdocs/archive/2026-09-20-flatbuffers-codec-design.md).- generate_
pipeline - The pipeline’s entry point: everything
generate_face_withemits, over the whole build, with an interface the face cannot carry skipped rather than refused (E11.14 decisions 1, 2 and 4). - generate_
with generatewith the other packages of the same build.- module_
segment - The Rust module-segment spelling of one typl package name segment:
modbecomesr#mod,cratebecomescrate_, and an ordinary segment is returned unchanged.