Current section
Files
Jump to
Current section
Files
src/libero@protocol.erl
-module(libero@protocol).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/libero/protocol.gleam").
-export([to_string/1, from_string/1]).
-export_type([protocol/0]).
-type protocol() :: etf | json.
-file("src/libero/protocol.gleam", 8).
-spec to_string(protocol()) -> binary().
to_string(Protocol) ->
case Protocol of
etf ->
<<"etf"/utf8>>;
json ->
<<"json"/utf8>>
end.
-file("src/libero/protocol.gleam", 15).
-spec from_string(binary()) -> {ok, protocol()} | {error, binary()}.
from_string(Value) ->
case string:lowercase(Value) of
<<"etf"/utf8>> ->
{ok, etf};
<<"json"/utf8>> ->
{ok, json};
Other ->
{error, <<"unknown protocol: "/utf8, Other/binary>>}
end.