libero/walker

Types

A single discovered variant to emit as a registerConstructor call.

pub type DiscoveredVariant {
  DiscoveredVariant(
    module_path: String,
    variant_name: String,
    atom_name: String,
    float_field_indices: List(Int),
  )
}

Constructors

  • DiscoveredVariant(
      module_path: String,
      variant_name: String,
      atom_name: String,
      float_field_indices: List(Int),
    )

    Arguments

    module_path

    Gleam module path, e.g. “shared/discount”.

    variant_name

    PascalCase constructor name, e.g. “AdminData”.

    atom_name

    snake_case atom name, e.g. “admin_data”.

    float_field_indices

    0-based indices of fields whose Gleam type is Float. Used by the JS ETF encoder to distinguish Int from Float (JS erases this distinction at runtime).

Values

pub fn to_snake_case(name: String) -> String

Convert a PascalCase variant name to snake_case for the wire atom. “AdminData” → “admin_data”, “One” → “one”, “TwoOrMore” → “two_or_more”. Handles consecutive uppercase: “XMLParser” → “xml_parser”. Must stay aligned with snakeCase() in rpc_ffi.mjs.

pub fn walk_message_registry_types(
  message_modules message_modules: List(scanner.MessageModule),
  module_files module_files: dict.Dict(String, String),
) -> Result(List(DiscoveredVariant), List(gen_error.GenError))

Walk the type graph rooted at MsgFromClient/MsgFromServer message types. Seeds the BFS walker from all variants of MsgFromClient and MsgFromServer custom types in each message module, then walks their field types transitively.

Both the MsgFromClient/MsgFromServer types themselves (and their constructors) and all transitively reachable types are included in the discovered list, since they all need codec registration.

Search Document