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