ActorSimulation.RactorGenerator (GenServerVirtualTime v0.6.0)

Copy Markdown View Source

Generates Rust code using the Ractor actor library from ActorSimulation DSL.

Ractor is a Rust actor framework inspired by Erlang's gen_server that provides:

  • Supervision trees (like OTP)
  • Named actor registry
  • Remote procedure calls (RPC)
  • Timers and scheduling
  • Runtime-agnostic design (Tokio-based)

This generator creates production-ready Rust projects with:

  • Ractor actor implementations
  • Callback traits for custom behavior
  • Comprehensive test suites (integration and unit tests)
  • GitHub Actions CI/CD
  • Complete documentation

Example

simulation = ActorSimulation.new()
  |> ActorSimulation.add_actor(:sender,
      send_pattern: {:periodic, 100, :msg},
      targets: [:receiver])
  |> ActorSimulation.add_actor(:receiver)

{:ok, files} = RactorGenerator.generate(simulation,
  project_name: "my_actors",
  enable_callbacks: true)

RactorGenerator.write_to_directory(files, "ractor_output/")

Summary

Functions

Generates complete Ractor (Rust) project files from an ActorSimulation.

Writes generated files to a directory.

Functions

generate(simulation, opts \\ [])

Generates complete Ractor (Rust) project files from an ActorSimulation.

Options

  • :project_name (required) - Name of the Cargo package (snake_case)
  • :enable_callbacks (default: true) - Generate callback traits
  • :rust_edition (default: "2021") - Rust edition for Cargo.toml
  • :ractor_version (default: "0.15") - Ractor crate version

Returns

{:ok, files} where files is a list of {filename, content} tuples

write_to_directory(files, output_dir)

Writes generated files to a directory.