-module(gleatter@path). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([static_path/1, id_path/1, complex_path/1, encode/2, decode/2, get_type/1]). -export_type([path_type/0, path_converter/1, route_path/1]). -type path_type() :: {static_path, list(binary())} | complex_path. -type path_converter(IJZ) :: {path_converter, fun((IJZ) -> list(binary())), fun((list(binary())) -> {ok, IJZ} | {error, nil})}. -opaque route_path(IKA) :: {route_path, path_type(), path_converter(IKA)}. -file("/home/runner/work/gleatter/gleatter/src/gleatter/path.gleam", 27). -spec static_path(list(binary())) -> route_path(nil). static_path(Root) -> {route_path, {static_path, Root}, {path_converter, fun(_) -> Root end, fun(Path) -> gleam@bool:guard( Path =:= Root, {ok, nil}, fun() -> {error, nil} end ) end}}. -file("/home/runner/work/gleatter/gleatter/src/gleatter/path.gleam", 43). -spec id_path(list(binary())) -> route_path(binary()). id_path(Root) -> {route_path, complex_path, {path_converter, fun(Id) -> lists:append(Root, [Id]) end, fun(Segs) -> Reverse_root = lists:reverse(Root), case lists:reverse(Segs) of [Id@1 | Rest] when Rest =:= Reverse_root -> {ok, Id@1}; _ -> {error, nil} end end}}. -file("/home/runner/work/gleatter/gleatter/src/gleatter/path.gleam", 61). -spec complex_path(path_converter(IKF)) -> route_path(IKF). complex_path(Converter) -> {route_path, complex_path, Converter}. -file("/home/runner/work/gleatter/gleatter/src/gleatter/path.gleam", 66). -spec encode(route_path(IKI), IKI) -> list(binary()). encode(Path, Value) -> _pipe = Value, (erlang:element(2, erlang:element(3, Path)))(_pipe). -file("/home/runner/work/gleatter/gleatter/src/gleatter/path.gleam", 71). -spec decode(route_path(IKL), list(binary())) -> {ok, IKL} | {error, nil}. decode(Path, Value) -> _pipe = Value, (erlang:element(3, erlang:element(3, Path)))(_pipe). -file("/home/runner/work/gleatter/gleatter/src/gleatter/path.gleam", 76). -spec get_type(route_path(any())) -> path_type(). get_type(Path) -> erlang:element(2, Path).