Migrate three pure-function modules from Elixir to Gleam: - polling_offset: deterministic hash-based polling offset (pure Gleam, no FFI) - changelog_parser: text parsing logic in Gleam, thin Elixir wrapper for File I/O - user_agent_parser: regex-based UA parsing in Gleam with Erlang FFI for atom-keyed map conversion Add gleam_regexp dependency for regex support in Gleam modules. Update all call sites and tests to use Gleam module atoms. Reviewed-on: graham/towerops-web#103
29 lines
1.3 KiB
Erlang
29 lines
1.3 KiB
Erlang
-module(snmpkit_error_ffi).
|
|
-export([atom_to_error_status/1, error_status_to_atom/1]).
|
|
|
|
%% Convert Elixir atom to Gleam ErrorStatus.
|
|
%% Gleam zero-field variants compile to bare atoms.
|
|
atom_to_error_status(no_error) -> no_error;
|
|
atom_to_error_status(too_big) -> too_big;
|
|
atom_to_error_status(no_such_name) -> no_such_name;
|
|
atom_to_error_status(bad_value) -> bad_value;
|
|
atom_to_error_status(read_only) -> read_only;
|
|
atom_to_error_status(gen_err) -> gen_err;
|
|
atom_to_error_status(no_access) -> no_access;
|
|
atom_to_error_status(wrong_type) -> wrong_type;
|
|
atom_to_error_status(wrong_length) -> wrong_length;
|
|
atom_to_error_status(wrong_encoding) -> wrong_encoding;
|
|
atom_to_error_status(wrong_value) -> wrong_value;
|
|
atom_to_error_status(no_creation) -> no_creation;
|
|
atom_to_error_status(inconsistent_value) -> inconsistent_value;
|
|
atom_to_error_status(resource_unavailable) -> resource_unavailable;
|
|
atom_to_error_status(commit_failed) -> commit_failed;
|
|
atom_to_error_status(undo_failed) -> undo_failed;
|
|
atom_to_error_status(authorization_error) -> authorization_error;
|
|
atom_to_error_status(not_writable) -> not_writable;
|
|
atom_to_error_status(inconsistent_name) -> inconsistent_name;
|
|
atom_to_error_status(_) -> unknown_error.
|
|
|
|
%% Convert Gleam ErrorStatus back to Elixir atom.
|
|
%% Identity since both are bare atoms.
|
|
error_status_to_atom(Status) -> Status.
|