libero/toml_config
TOML configuration parser for Libero v4.
Reads the [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,
rest: Bool,
clients: List(ClientConfig),
server_src_dir: String,
server_generated_dir: String,
server_atoms_path: String,
shared_src_dir: String,
shared_state_module: String,
app_error_module: String,
)
}
Constructors
-
TomlConfig( name: String, port: Int, rest: Bool, clients: List(ClientConfig), server_src_dir: String, server_generated_dir: String, server_atoms_path: String, shared_src_dir: String, shared_state_module: String, app_error_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/server/generated”.
- server_atoms_path
-
Path to the atoms .erl file. Default: “src/
@generated@rpc_atoms.erl”. - shared_src_dir
-
Directory containing shared source (where message modules live). Libero scans this directory for MsgFromClient/MsgFromServer types. Default: “shared/src/shared” - a separate target-agnostic package. Required for projects with both an Erlang server and a JS client: if messages lived in the server package, the JS client couldn’t import them without pulling in wisp/sqlight (Erlang-only FFI).
- shared_state_module
-
Gleam module path to the SharedState type used by libero dispatch. Default: “server/shared_state”.
- app_error_module
-
Gleam module path to the AppError type used by libero dispatch. Default: “server/app_error”.
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