Expand description
Rust consumer for compactc’s contract.mpir.
The runtime IR is a language-agnostic CBOR (RFC 8949) serialization
of the post-analysis Compact IR (Ltypescript). This crate parses
it into typed Rust structures so consumers can drive contract
behaviour without the @midnight-ntwrk/compact-runtime JS
dependency.
The IR schema is specified at compact/doc/runtime-ir.md (in the
patched compactc fork). This crate’s types mirror the schema 1:1;
every CBOR construct the emitter produces has a matching Rust enum
variant.
Re-exports§
pub use de::FromValueError;pub use de::from_runtime_value;pub use error::IrError;pub use error::Result;pub use ir::AdtOpInvocation;pub use ir::Argument;pub use ir::CapabilitiesMeta;pub use ir::CapabilityDef;pub use ir::CapabilityKind;pub use ir::CircuitBody;pub use ir::CircuitBoundsMeta;pub use ir::CircuitCapUsage;pub use ir::Constructor;pub use ir::DebugInfo;pub use ir::Expression;pub use ir::FieldRole;pub use ir::FieldType;pub use ir::FrontendLanguage;pub use ir::FrontendMeta;pub use ir::GovernanceSpec;pub use ir::LedgerField;pub use ir::MoonIr;pub use ir::Native;pub use ir::PathElement;pub use ir::PrivacyClass;pub use ir::PrivacyMeta;pub use ir::SemanticTypeRole;pub use ir::SourceSpan;pub use ir::Statement;pub use ir::TypeDescriptor;pub use ir::VmInstr;pub use ir::VmOp;pub use ir::Witness;pub use ir::WorkflowMeta;pub use ir::WorkflowStepMeta;pub use ir::canonical_intrinsic_name;pub use layout::AtomLayout;pub use layout::ChunkOrder;pub use layout::FieldLayout;pub use layout::ForeignFieldSplit;pub use loader::MIN_SCHEMA_VERSION;pub use loader::MOON_IR_FILENAME;pub use loader::SUPPORTED_SCHEMA_VERSION;pub use loader::from_cbor_slice;pub use loader::from_path;pub use loader::to_cbor_vec;pub use loader::write_cbor;pub use ser::ToValueError;pub use ser::to_runtime_value;pub use value::RuntimeValue;
Modules§
- cbor_
fast - Zero-copy single-pass RFC 8949 CBOR decoder for
MoonIr. - de
- Deserialize a typed
T: Deserializedirectly from an in-memoryRuntimeValuetree — no CBOR/JSON round-trip. - error
- ir
- Typed IR mirroring the contract.mpir schema 1:1.
- layout
- Pure, dependency-free single source of truth for FAB
AlignedValue↔ ZKIR v3 field-element layout. - loader
- Load + parse
contract.mpirinto typedcrate::ir::MoonIr. - present
- A
RuntimeValueas a host language shows it, decided once for every binding: each one (the console, Node, other languages) turns aPresentedinto its own values mechanically, so a value reads the same in all of them. - ser
- Serialize any
T: Serializedirectly into an in-memoryRuntimeValuetree — the symmetric counterpart tocrate::de::from_runtime_value. - value
RuntimeValue— the dynamically-typed value enum the IR interpreter and witness backends carry on the operand stack.