Current section
Files
Jump to
Current section
Files
src/gftp@response.erl
-module(gftp@response).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/gftp/response.gleam").
-export([describe/1, to_string/1]).
-export_type([response/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(" FTP Response returned by the server.\n").
-type response() :: {response, gftp@status:status(), bitstring()}.
-file("src/gftp/response.gleam", 14).
?DOC(
" The message_to_string function takes a BitArray and converts it to a String.\n"
" If the BitArray is not valid UTF-8, it returns an error message.\n"
).
-spec message_to_string(bitstring()) -> binary().
message_to_string(Message) ->
_pipe = Message,
_pipe@1 = gleam@bit_array:to_string(_pipe),
gleam@result:unwrap(_pipe@1, <<"Invalid UTF-8 in response message"/utf8>>).
-file("src/gftp/response.gleam", 21).
?DOC(" The describe function takes a Response and returns a human-readable string describing the response.\n").
-spec describe(response()) -> binary().
describe(Response) ->
<<<<<<"["/utf8, (gftp@status:describe(erlang:element(2, Response)))/binary>>/binary,
"] "/utf8>>/binary,
(message_to_string(erlang:element(3, Response)))/binary>>.
-file("src/gftp/response.gleam", 28).
-spec to_string(response()) -> {ok, binary()} | {error, nil}.
to_string(Response) ->
gleam@bit_array:to_string(erlang:element(3, Response)).