Skip to main content

src/sendr@message@mailbox.erl

-module(sendr@message@mailbox).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/sendr/message/mailbox.gleam").
-export([new/2]).
-export_type([mailbox/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(
    " This module provides a lax representation of a mailbox as defined in\n"
    " [RFC 5322, section 3.4.1](https://tools.ietf.org/html/rfc5322#section-3.4.1).\n"
    "\n"
    " It does not enforce any of the rules and requirements of the RFC. Since we\n"
    " do not know what transformations the Mail Submission Agent will perform and\n"
    " what the Mail Submission Agent is capable of handling.\n"
).

-type mailbox() :: {mailbox, binary(), binary()}.

-file("src/sendr/message/mailbox.gleam", 23).
?DOC(
    " Creates a new `Mailbox` with a display name and an address.\n"
    " The display name and address are trimmed of leading and trailing whitespace.\n"
).
-spec new(binary(), binary()) -> mailbox().
new(Name, Address) ->
    {mailbox, gleam@string:trim(Name), gleam@string:trim(Address)}.