Current section
Files
Jump to
Current section
Files
src/json_canvas@edge@endpoint_shape.erl
-module(json_canvas@edge@endpoint_shape).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([decode_endpoint_shape/1]).
-export_type([endpoint_shape/0]).
-type endpoint_shape() :: with_arrow | without_arrow.
-spec decode_endpoint_shape(gleam@dynamic:dynamic_()) -> {ok, endpoint_shape()} |
{error, list(gleam@dynamic:decode_error())}.
decode_endpoint_shape(Dyn) ->
gleam@result:'try'(gleam@dynamic:string(Dyn), fun(Shape) -> case Shape of
<<"none"/utf8>> ->
{ok, without_arrow};
<<"arrow"/utf8>> ->
{ok, with_arrow};
_ ->
{error,
[{decode_error, <<"none or arrow"/utf8>>, Shape, []}]}
end end).