libero/walker

Types

A custom type discovered by the walker, grouping all its variants.

pub type DiscoveredType {
  DiscoveredType(
    module_path: String,
    type_name: String,
    type_params: List(String),
    variants: List(DiscoveredVariant),
  )
}

Constructors

  • DiscoveredType(
      module_path: String,
      type_name: String,
      type_params: List(String),
      variants: List(DiscoveredVariant),
    )

A single discovered variant, used in typed decoder codegen.

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

Constructors

  • DiscoveredVariant(
      module_path: String,
      variant_name: String,
      atom_name: String,
      float_field_indices: List(Int),
      fields: List(field_type.FieldType),
    )

    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).

    fields

    Structured types of each field, in declaration order.

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_shared_types(
  shared_src shared_src: String,
) -> Result(List(DiscoveredType), List(gen_error.GenError))

Walk all exported custom types from a list of shared source files. Seeds from every public type in shared/, since the codegen pipeline needs decoders for any type that may appear in a handler’s params or return type.

Search Document