tpt-telos-codegen
Rust/Go dual-backend code generation and FFI bridge for tpt-telos.
Part of the tpt-telos compiler workspace.
Overview
tpt-telos-codegen is the final emission stage of the tpt-telos pipeline. It consumes the verified
FuncOutcomes produced by tpt-telos-agent and emits human-readable, compilable source code.
generate_program— emits a single self-contained Rust library file (structs, invariantimplmethods, contract doc-comments, onefnper function).generate_project— assembles a full dual-backend project tree: a Rust crate, a Go module, and a C-ABI FFI bridge between them, with each module routed to Rust or Go bytpt-telos-router.- eject hatch — functions marked
@ejectare compiled to a trusted opaquef_implstub wrapped by a generated guard that enforcesrequires/ensuresat runtime viaassert!.
Usage
use ;
// Single Rust file
let rust_src = generate_program;
write.unwrap;
// Full dual-backend project
let project = generate_project;
for file in &project.files
Key API
| Item | Description |
|---|---|
generate_program(modules, outcomes) -> String |
Single Rust library source |
generate_project(modules, outcomes) -> Project |
Full Rust+Go project tree |
Project |
Collection of GeneratedFile { path, contents } |
eject::render_rust_ejected |
Opaque stub + contract-guarded wrapper |
go module |
Go backend emitter |
ffi module |
C-ABI FFI bridge generator |
License
Licensed under either of MIT or Apache-2.0 at your option.