Skip to main content

Crate rialo_venus_dsl

Crate rialo_venus_dsl 

Source
Expand description

§Rialo Workflow Macro (V2 - syngen-generated parser)

This crate provides the rialo! procedural macro for generating Solana program interfaces and implementations from high-level workflow definitions. The macro follows a classic compiler architecture pattern:

Parse → Model → Transform → Generate

§Architecture Overview

The compilation pipeline consists of four main phases:

  1. Parse (parse module): Converts macro input tokens into an internal data model using syngen-generated parser
  2. Model (model module): Provides the internal representation of workflow components
  3. Transform (transform module): Analyzes and transforms the model for code generation
  4. Generate (generate module): Produces Solana program code from the transformed model

§Key Concepts

  • Workflow State: Persistent data structure that survives across async operations
  • Workflow Program: Collection of functions that define the workflow’s behavior
  • Function Types: Different categories of functions (initiating, handler, control, terminating, internal)
  • Async Operations: Venus DSL syntax (AFTER, EVERY, ON, SEND, START) that are transformed into Solana program calls
  • Resource Analysis: Automatic calculation of required Solana accounts based on async operations

§Input Format

ⓘ
rialo! {
    state {
        // Persistent state fields
        field_name: Type,
    }

    program {
        // Use statements and function definitions
        use some_crate::SomeType;

        initiating fn entry_point(&mut self, param: Type) -> ProgramResult {
            // Function body with Venus DSL async syntax
        }

        handler fn async_callback(&mut self, data: Type) -> ProgramResult {
            // Handler function body
        }
    }
}

§Generated Code Structure

The macro generates two main modules:

  • interface: Instruction definitions and constructors (always generated)
  • implementation: Program logic, state struct, and Solana entrypoint (feature-gated)

§Example Usage

ⓘ
use crate::workflow;

rialo! {
    state {
        counter: u64,
        next_timestamp: u64,
    }

    program {
        use rialo_s_program::entrypoint::ProgramResult;

        initiating fn start(&mut self, frequency: u64) -> ProgramResult {
            self.next_timestamp = self.unix_timestamp() as u64 + frequency;
            AFTER self.next_timestamp seconds CALL self.tick();
            Ok(())
        }

        handler fn tick(&mut self, _now: u64) -> ProgramResult {
            self.counter += 1;
            Ok(())
        }
    }
}

Re-exports§

pub use model::Model;
pub use model::WorkflowBlock;

Modules§

generate
generate_client
Client crate generation for Venus programs.
generate_manifest
Venus Manifest generation for workflow testing
generate_rex_wasm
Generate WASM component source code from rex block functions.
generate_server_wit
Server-side WIT generation for Venus workflows
model
Model Module
parse
Parse Module
transform

Functions§

generate
Generate Solana program code from a workflow model.
parse_from_str
Parse a Venus DSL program from a string