Current section
Files
Jump to
Current section
Files
src/sparkleplug@sparkplug_b@topic_namespace.erl
-module(sparkleplug@sparkplug_b@topic_namespace).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([from_string/1, to_string/1]).
-export_type([topic_namespace/0, topic_namespace_parse_error/0]).
-type topic_namespace() :: sp_av10 | sp_bv10.
-type topic_namespace_parse_error() :: {topic_namespace_parse_error, binary()}.
-file("C:\\Users\\kavan\\Documents\\GitHub\\sparkleplug\\src\\sparkleplug\\sparkplug_b\\topic_namespace.gleam", 6).
-spec from_string(binary()) -> {ok, topic_namespace()} |
{error, topic_namespace_parse_error()}.
from_string(Namespace_string) ->
case Namespace_string of
<<"SpAv1.0"/utf8>> ->
{ok, sp_av10};
<<"SpBv1.0"/utf8>> ->
{ok, sp_bv10};
_ ->
{error,
{topic_namespace_parse_error,
<<"Couldn't parse topic namespace from string."/utf8>>}}
end.
-file("C:\\Users\\kavan\\Documents\\GitHub\\sparkleplug\\src\\sparkleplug\\sparkplug_b\\topic_namespace.gleam", 19).
-spec to_string(topic_namespace()) -> binary().
to_string(Topic_namespace) ->
case Topic_namespace of
sp_av10 ->
<<"SpAv1.0"/utf8>>;
sp_bv10 ->
<<"SpBv1.0"/utf8>>
end.