Skip to main content

Crate assura_codegen

Crate assura_codegen 

Source
Expand description

Rust code generation from type-checked Assura contracts.

Takes a TypedFile from assura-types and generates a Rust project consisting of a Cargo.toml and one or more .rs source files. Generated Rust is formatted via prettyplease.

This is T019: the initial scaffolding. Type mapping (T020), contract codegen (T021), project generation (T022), and struct/enum codegen (T023) extend this foundation.

Modules§

features
Feature-specific code generation for all 50 verification features. Feature-specific Rust code generation for Assura’s 50 verification features.
hir
Typed Rust HIR for structured code generation. Typed Rust HIR (High-level Intermediate Representation) for codegen.
metadata
Structured contract metadata for AI agent consumption. Structured contract metadata for generated Rust projects.
type_map
Assura-to-Rust type mapping (Int -> i64, Nat -> u64, etc.). Reverse type mapping: Rust types to Assura types.

Structs§

BackendConfig
Configuration for code generation.
GeneratedProject
The result of code generation: a complete Rust project.

Enums§

CodegenBackend
Code generation backend.
CompileTarget
Compilation target for the generated Rust project.

Functions§

codegen
Generate a Rust project from a type-checked Assura file.
codegen_with_config
Generate a Rust project from a type-checked Assura file.
collect_contract_params
Collect the effective input parameters for a contract declaration.
expr_to_rust_static
Convert an Assura Expr to a Rust expression for use in const context.
extract_input_params
Extract (name, rust_type) pairs from an input clause body.
map_type_token
Map a single Assura type token to its Rust equivalent.
map_type_tokens
Convert an Assura type token sequence (e.g., ["List", "<", "Int", ">"]) to a valid Rust type string.