Current section
Files
Jump to
Current section
Files
src/postgleam@codec@circle.erl
-module(postgleam@codec@circle).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/postgleam/codec/circle.gleam").
-export([encode/1, decode/1, matcher/0]).
-file("src/postgleam/codec/circle.gleam", 30).
-spec encode(postgleam@value:value()) -> {ok, bitstring()} | {error, binary()}.
encode(Val) ->
case Val of
{circle, X, Y, Radius} ->
{ok, <<X:64/float-big, Y:64/float-big, Radius:64/float-big>>};
_ ->
{error, <<"circle codec: expected Circle value"/utf8>>}
end.
-file("src/postgleam/codec/circle.gleam", 38).
-spec decode(bitstring()) -> {ok, postgleam@value:value()} | {error, binary()}.
decode(Data) ->
case Data of
<<X:64/float-big, Y:64/float-big, Radius:64/float-big>> ->
{ok, {circle, X, Y, Radius}};
_ ->
{error, <<"circle codec: expected 24 bytes"/utf8>>}
end.
-file("src/postgleam/codec/circle.gleam", 20).
-spec build(integer()) -> postgleam@codec:codec().
build(Type_oid) ->
{codec, <<"circle"/utf8>>, Type_oid, binary, fun encode/1, fun decode/1}.
-file("src/postgleam/codec/circle.gleam", 10).
-spec matcher() -> postgleam@codec:codec_matcher().
matcher() ->
{codec_matcher, <<"circle"/utf8>>, [718], none, binary, fun build/1}.