libero/toml_config

TOML configuration parser for Libero.

Reads the [tools.libero] section from gleam.toml.

Types

pub type ClientConfig {
  ClientConfig(name: String, target: String)
}

Constructors

  • ClientConfig(name: String, target: String)
pub type TomlConfig {
  TomlConfig(
    name: String,
    port: Int,
    clients: List(ClientConfig),
    server_src_dir: String,
    server_generated_dir: String,
    server_atoms_path: String,
    shared_src_dir: String,
    context_module: String,
  )
}

Constructors

  • TomlConfig(
      name: String,
      port: Int,
      clients: List(ClientConfig),
      server_src_dir: String,
      server_generated_dir: String,
      server_atoms_path: String,
      shared_src_dir: String,
      context_module: String,
    )

    Arguments

    server_src_dir

    Directory containing server source (where handler modules live). Default: “src” (package root).

    server_generated_dir

    Directory where libero writes server-side generated code (dispatch, websocket). Default: “src/generated” (relative to server package root).

    server_atoms_path

    Path to the atoms .erl file. Default: “src/@generated@rpc_atoms.erl”.

    shared_src_dir

    Directory containing shared source (types referenced by handler signatures). Libero walks every public type here so it can emit decoders for anything reachable from a handler’s params or return type. Default: “../shared/src/shared” (relative to server package root) - a separate target-agnostic package. Required for projects with both an Erlang server and a JS client: if shared types lived in the server package, the JS client couldn’t import them without pulling in wisp/sqlight (Erlang-only FFI).

    context_module

    Gleam module path to the HandlerContext type used by libero dispatch. Default: “handler_context”.

Values

pub fn parse(input: String) -> Result(TomlConfig, String)

Parse a TOML string into a TomlConfig.

Returns Error(String) for parse failures or missing required fields. nolint: stringly_typed_error, error_context_lost – config parsing; tom errors are opaque, string messages are more useful

pub fn to_codegen_config(
  toml_cfg toml_cfg: TomlConfig,
  client client_name: String,
  ws_path ws_path: String,
) -> Result(config.Config, String)

Convert a TomlConfig and client name into the Config type used by the codegen pipeline. nolint: stringly_typed_error, error_context_lost

Search Document