Current section
Files
Jump to
Current section
Files
src/touch_grass@download.erl
-module(touch_grass@download).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/touch_grass/download.gleam").
-export([lift/0, lower/0, decode/1, encode/1]).
-export_type([input/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(
" Download is a version of save, but with a name and not a path.\n"
" A separate effect is a choice instead of using a magic directory in the filesystem.\n"
).
-type input() :: {input, binary(), bitstring()}.
-file("src/touch_grass/download.gleam", 11).
-spec lift() -> eyg@analysis@type_@isomorphic:type(any()).
lift() ->
{record,
{row_extend,
<<"name"/utf8>>,
string,
{row_extend, <<"content"/utf8>>, binary, empty}}}.
-file("src/touch_grass/download.gleam", 15).
-spec lower() -> eyg@analysis@type_@isomorphic:type(any()).
lower() ->
{record, empty}.
-file("src/touch_grass/download.gleam", 23).
-spec decode(eyg@interpreter@value:value(NDQ, NDR)) -> {ok, input()} |
{error, eyg@interpreter@break:reason(NDQ, NDR)}.
decode(Lift) ->
gleam@result:'try'(
eyg@interpreter@cast:field(
<<"name"/utf8>>,
fun eyg@interpreter@cast:as_string/1,
Lift
),
fun(Name) ->
gleam@result:'try'(
eyg@interpreter@cast:field(
<<"content"/utf8>>,
fun eyg@interpreter@cast:as_binary/1,
Lift
),
fun(Content) -> {ok, {input, Name, Content}} end
)
end
).
-file("src/touch_grass/download.gleam", 29).
-spec encode({ok, nil} | {error, binary()}) -> eyg@interpreter@value:value(any(), any()).
encode(Result) ->
case Result of
{ok, nil} ->
eyg@interpreter@value:ok(eyg@interpreter@value:unit());
{error, Reason} ->
eyg@interpreter@value:error({string, Reason})
end.