MoonMail

the catalogue · api reference

Every part,
on its own card.

nine packages, one mailroom. Each card is a package; the two that are one subject — the objects and the check on them — share a card. The slips hanging under it are what the package exposes, in the order you are likely to reach for them.

9packages 4protocols 6sasl mechanisms 0.2.2interface
Lush green rainforest leaves in sunlight 01
moonmail

The message itself

Addresses, ordered headers, a tree of parts, and a builder that picks the right nesting for you.

RFC 5322 RFC 2045 RFC 6532 12 entries
fn fn encode_addresses(ArrayView[Address], utf8? : Bool) -> String
fn fn format_date(@moondate.Moment) -> String
fn fn parse_address(StringView) -> Address raise Refused
fn fn parse_addresses(StringView) -> Array[Address] raise Refused
fn fn parse_date(StringView) -> @moondate.Moment raise Refused
enum enum Address { Mailbox(Mailbox); Group(name~ : String, members~ : Array[Mailbox]) } fn Address::encode(Self, utf8? : Bool) -> String fn Address::mailboxes(Self) -> Array[Mailbox]
struct struct Attachment
  • name : String
  • media_type : String
  • data : Bytes
  • inline : Bool
  • id : String?
fn Attachment::new(String, Bytes, media_type? : String, inline? : Bool, id? : String) -> Self
enum enum Body { Leaf(Bytes); Multipart(Array[Message]); Embedded(Message) }
struct struct Headers // private fields fn Headers::add(Self, String, String) -> Unit raise Refused fn Headers::all(Self, StringView) -> Array[String] fn Headers::get(Self, StringView) -> String? fn Headers::iter(Self) -> Iter[(String, String)] fn Headers::length(Self) -> Int32 fn Headers::new() -> Self fn Headers::remove(Self, StringView) -> Unit fn Headers::set(Self, String, String) -> Unit raise Refused
struct struct Mailbox { name : String?; address : String } fn Mailbox::encode(Self, utf8? : Bool) -> String fn Mailbox::new(String, name? : String) -> Self
struct struct Message { headers : Headers; body : Body } fn Message::addresses(Self, StringView) -> Array[Address] raise Refused fn Message::attachments(Self) -> Array[Attachment] fn Message::bcc(Self) -> Array[Address] raise Refused fn Message::cc(Self) -> Array[Address] raise Refused fn Message::content_type(Self) -> @moonmime.MediaType fn Message::date(Self) -> @moondate.Moment? raise Refused fn Message::encode(Self, utf8? : Bool) -> Bytes fn Message::from(Self) -> Array[Mailbox] raise Refused fn Message::html(Self, charsets? : Map[String, &@moonmime.Charset]) -> String? raise Refused fn Message::message_id(Self) -> String? fn Message::new(from~ : Mailbox, to~ : Array[Address], subject~ : String, text? : String, html? : String, attachments? : Array[Attachment], cc? : Array[Address], date? : @moondate.Moment, message_id? : String) -> Self raise Refused fn Message::parse(BytesView, strict? : Bool) -> Self raise Refused fn Message::reply_to(Self) -> Array[Address] raise Refused fn Message::subject(Self) -> String? fn Message::text(Self, charsets? : Map[String, &@moonmime.Charset]) -> String? raise Refused fn Message::to(Self) -> Array[Address] raise Refused
suberror suberror Refused
  • Header(at~ : Int32)
  • Address(at~ : Int32)
  • Boundary(at~ : Int32)
  • Encoding(at~ : Int32)
  • Charset(name~ : String)
  • Date
An orange autumn forest with a soft path 02
moonmail/dkim

Sign it, then check the claim

One signature over the headers you name and the body you hash, and a verdict for every signature a letter carries.

RFC 6376 RFC 8463 7 entries
fn fn sign(BytesView, Key, domain~ : String, selector~ : String, headers? : Array[String], header_canon? : Canon, body_canon? : Canon, timestamp? : Int64, expire? : Int64, length? : Bool, identity? : String) -> String raise Refused
value let signed : Array[String]
fn fn verify(BytesView, (String) -> String? raise, now~ : Int64) -> Array[Verdict]
enum enum Canon { Simple; Relaxed }
enum enum Key { Rsa(@rsa.PrivateKey); Ed25519(@ed25519.PrivateKey) }
enum enum Verdict
  • Pass(domain~ : String, selector~ : String)
  • Fail(domain~ : String, reason~ : String)
  • PermError(String)
  • TempError(String)
suberror suberror Refused { Missing(String); Malformed(String) }
Golden desert dunes under a pale sky 03
moonmail/sasl

Mechanisms, as a trait

Six mechanisms behind one trait, so a mechanism written once works on all three protocols.

RFC 4616 RFC 7677 RFC 7628 10 entries
fn fn prep(StringView, unassigned? : Bool) -> String raise Refused
fn fn respond(&Mechanism, StringView) -> String raise Refused
struct struct CramMd5 // private fields impl Mechanism for CramMd5 fn CramMd5::finish(Self) -> Unit raise Refused fn CramMd5::name(Self) -> String fn CramMd5::new(String, String) -> Self fn CramMd5::start(Self) -> Bytes? fn CramMd5::step(Self, BytesView) -> Bytes raise Refused
struct struct Login // private fields impl Mechanism for Login fn Login::finish(Self) -> Unit raise Refused fn Login::name(Self) -> String fn Login::new(String, String) -> Self fn Login::start(Self) -> Bytes? fn Login::step(Self, BytesView) -> Bytes raise Refused
struct struct OAuthBearer // private fields impl Mechanism for OAuthBearer fn OAuthBearer::error(Self) -> String? fn OAuthBearer::finish(Self) -> Unit raise Refused fn OAuthBearer::name(Self) -> String fn OAuthBearer::new(String, username? : String, host? : String, port? : Int32) -> Self fn OAuthBearer::start(Self) -> Bytes? fn OAuthBearer::step(Self, BytesView) -> Bytes raise Refused
struct struct Plain // private fields impl Mechanism for Plain fn Plain::finish(Self) -> Unit raise Refused fn Plain::name(Self) -> String fn Plain::new(String, String, authzid? : String) -> Self fn Plain::start(Self) -> Bytes? fn Plain::step(Self, BytesView) -> Bytes raise Refused
struct struct ScramSha256 // private fields impl Mechanism for ScramSha256 fn ScramSha256::finish(Self) -> Unit raise Refused fn ScramSha256::name(Self) -> String fn ScramSha256::new(String, String, nonce~ : String) -> Self raise Refused fn ScramSha256::start(Self) -> Bytes? fn ScramSha256::step(Self, BytesView) -> Bytes raise Refused
struct struct XOAuth2 // private fields impl Mechanism for XOAuth2 fn XOAuth2::error(Self) -> String? fn XOAuth2::finish(Self) -> Unit raise Refused fn XOAuth2::name(Self) -> String fn XOAuth2::new(String, String) -> Self fn XOAuth2::start(Self) -> Bytes? fn XOAuth2::step(Self, BytesView) -> Bytes raise Refused
trait trait Mechanism
  • fn name(Self) -> String
  • fn start(Self) -> Bytes?
  • fn step(Self, BytesView) -> Bytes raise Refused
  • fn finish(Self) -> Unit raise Refused = _
suberror suberror Refused
  • Prep(Char)
  • Malformed(String)
  • Server(String)
  • Signature
A turquoise river winding through forested hills 04
moonmail/smtp

Both ends of the relay

A client that paces commands by the extensions a server announced, and a server that answers the protocol itself.

RFC 5321 RFC 1870 RFC 3207 RFC 4954 12 entries
value let limits : Limits
enum enum Body { SevenBit; EightBit; Binary }
struct struct Client // private fields fn Client::auth(Self, &@sasl.Mechanism) -> Unit raise Refused fn Client::bdat(Self, BytesView, last? : Bool) -> Unit raise Refused fn Client::data(Self, BytesView) -> Unit raise Refused fn Client::ehlo(Self, String) -> Unit raise Refused fn Client::expn(Self, String) -> Unit raise Refused fn Client::extensions(Self) -> Map[String, String] fn Client::feed(Self, BytesView) -> Array[Event] raise Refused fn Client::has(Self, String) -> Bool fn Client::helo(Self, String) -> Unit raise Refused fn Client::help(Self, topic? : String) -> Unit raise Refused fn Client::mail(Self, String, size? : Int32, body? : Body, utf8? : Bool, ret? : Ret, envid? : String, auth? : String) -> Unit raise Refused fn Client::new(lmtp? : Bool, limits? : Limits) -> Self fn Client::next_write(Self) -> Bytes? fn Client::noop(Self) -> Unit fn Client::pending(Self) -> Int32 fn Client::quit(Self) -> Unit fn Client::rcpt(Self, String, notify? : Array[Notify], orcpt? : String) -> Unit raise Refused fn Client::rset(Self) -> Unit fn Client::send(Self, String, Array[String], BytesView) -> Unit raise Refused fn Client::starttls(Self) -> Unit raise Refused fn Client::vrfy(Self, String) -> Unit raise Refused
enum enum Command
  • Greeting
  • Hello(String)
  • StartTls
  • Auth(String)
  • Mail(String)
  • Rcpt(String)
  • Data
  • Bdat(Int32)
  • Delivery(String)
  • Rset
  • Noop
  • Vrfy(String)
  • Expn(String)
  • Help
  • Quit
enum enum Event { Reply(Command, Reply); Sasl(@sasl.Refused) }
struct struct Limits { line : Int32; recipients : Int32; size : Int32 } fn Limits::new(line? : Int32, recipients? : Int32, size? : Int32) -> Self
enum enum Notify { Success; Failure; Delay }
struct struct Reply { code : Int32; lines : Array[String] } fn Reply::encode(Self) -> Bytes fn Reply::is_ok(Self) -> Bool fn Reply::new(Int32, StringView) -> Self fn Reply::status(Self) -> String? fn Reply::text(Self) -> String
enum enum Request
  • Hello(String, extended~ : Bool)
  • StartTls
  • Auth(String, Bytes?)
  • Response(Bytes)
  • Mail(String, Map[String, String?])
  • Rcpt(String, Map[String, String?])
  • Data(Bytes)
  • Vrfy(String)
  • Expn(String)
  • Rset
  • Quit
enum enum Ret { Full; Headers }
struct struct Server // private fields fn Server::accept(Self) -> Unit raise Refused fn Server::challenge(Self, BytesView) -> Unit raise Refused fn Server::closed(Self) -> Bool fn Server::feed(Self, BytesView) -> Unit fn Server::new(String, lmtp? : Bool, starttls? : Bool, auth? : Array[String], greeting? : String, limits? : Limits) -> Self fn Server::next(Self) -> Request? fn Server::next_write(Self) -> Bytes? fn Server::reply(Self, Int32, String) -> Unit raise Refused
suberror suberror Refused
  • Malformed(String)
  • Exceeded(limit~ : Int32, got~ : Int32)
  • Order(String)
  • Unsupported(String)
A clear turquoise lake ringed by pines 05
moonmail/imap

Stay in the mailbox

IMAP4rev2 with IDLE and CONDSTORE. Every command gets a tag and every response comes back decoded.

RFC 9051 RFC 2177 RFC 7162 16 entries
value let limits : Limits
value let supported : Array[String]
struct struct Client // private fields fn Client::append(Self, String, BytesView, flags? : Array[String], date? : String) -> Int32 raise Refused fn Client::authenticate(Self, &@sasl.Mechanism) -> Int32 raise Refused fn Client::capabilities(Self) -> Array[String] fn Client::capability(Self) -> Int32 fn Client::close(Self) -> Int32 raise Refused fn Client::copy(Self, String, String, uid? : Bool) -> Int32 raise Refused fn Client::create(Self, String) -> Int32 raise Refused fn Client::delete(Self, String) -> Int32 raise Refused fn Client::done(Self) -> Unit raise Refused fn Client::enable(Self, Array[String]) -> Int32 raise Refused fn Client::examine(Self, String, condstore? : Bool) -> Int32 raise Refused fn Client::expunge(Self) -> Int32 raise Refused fn Client::feed(Self, BytesView) -> Array[Event] raise Refused fn Client::fetch(Self, String, String, uid? : Bool, changedsince? : Int64) -> Int32 raise Refused fn Client::has(Self, String) -> Bool fn Client::id(Self, Array[(String, String)]) -> Int32 raise Refused fn Client::idle(Self) -> Int32 raise Refused fn Client::list(Self, String, String) -> Int32 raise Refused fn Client::login(Self, String, String) -> Int32 raise Refused fn Client::logout(Self) -> Int32 fn Client::move_to(Self, String, String, uid? : Bool) -> Int32 raise Refused fn Client::namespaces(Self) -> Int32 raise Refused fn Client::new(limits? : Limits) -> Self fn Client::next_write(Self) -> Bytes? fn Client::noop(Self) -> Int32 fn Client::pending(Self) -> Int32 fn Client::rename(Self, String, String) -> Int32 raise Refused fn Client::search(Self, String, uid? : Bool) -> Int32 raise Refused fn Client::select(Self, String, condstore? : Bool) -> Int32 raise Refused fn Client::starttls(Self) -> Int32 raise Refused fn Client::state(Self) -> State fn Client::status(Self, String, Array[String]) -> Int32 raise Refused fn Client::store(Self, String, String, uid? : Bool, unchangedsince? : Int64) -> Int32 raise Refused fn Client::subscribe(Self, String) -> Int32 raise Refused fn Client::uid_expunge(Self, String) -> Int32 raise Refused fn Client::unselect(Self) -> Int32 raise Refused fn Client::unsubscribe(Self, String) -> Int32 raise Refused
enum enum Code
  • Alert
  • Capability(Array[String])
  • PermanentFlags(Array[String])
  • ReadOnly
  • ReadWrite
  • TryCreate
  • UidNext(Int64)
  • UidValidity(Int64)
  • HighestModseq(Int64)
  • NoModseq
  • Modified(String)
  • AppendUid(Int64, String)
  • CopyUid(Int64, String, String)
  • Closed
  • Other(String, String?)
enum enum Event
  • Data(Response)
  • Done(Int32, Status, Code?, String)
  • Sasl(@sasl.Refused)
struct struct Limits { line : Int32; literal : Int32 } fn Limits::new(line? : Int32, literal? : Int32) -> Self
enum enum Listing { All; Subscribed }
enum enum Response
  • Condition(String, Code?, String)
  • Capability(Array[String])
  • Enabled(Array[String])
  • Flags(Array[String])
  • Exists(Int64)
  • Expunge(Int64)
  • List(listing~ : Listing, flags~ : Array[String], delimiter~ : String?, name~ : String, extended~ : Array[Value])
  • Status(String, Map[String, Int64])
  • Esearch(tag~ : String?, uid~ : Bool, items~ : Map[String, Value])
  • Search(Array[Int64], modseq~ : Int64?)
  • Fetch(Int64, Map[String, Value])
  • Namespace(Value, Value, Value)
  • Other(String, Array[Value])
struct struct Server // private fields fn Server::feed(Self, BytesView) -> Unit raise Refused fn Server::new(store~ : Store, credentials~ : (String, String) -> Bool, clock~ : () -> String, limits? : Limits) -> Self fn Server::next_write(Self) -> Bytes? fn Server::state(Self) -> State
enum enum State
  • NotAuthenticated
  • Authenticated
  • Selected(String)
  • Logout
enum enum Status { Ok; No; Bad }
struct struct Store // private fields fn Store::clear(Self, String) -> Unit fn Store::create(Self, String) -> Bool fn Store::deliver(Self, String, BytesView, flags? : Array[String], date? : String) -> Int32? fn Store::exists(Self, String) -> Bool fn Store::expunge(Self, String) -> Array[Int32] fn Store::flags(Self, String) -> Array[String] fn Store::messages(Self, String) -> Array[Stored] fn Store::names(Self) -> Array[String] fn Store::new() -> Self fn Store::remove(Self, String) -> Bool fn Store::rename(Self, String, String) -> Bool fn Store::set_flags(Self, String, Int32, String, Array[String]) -> Array[String]? fn Store::subscribe(Self, String) -> Bool fn Store::subscribed(Self, String) -> Bool fn Store::summary(Self, String) -> Summary? fn Store::uidnext(Self, String) -> Int32 fn Store::unsubscribe(Self, String) -> Bool
struct struct Stored
  • uid : Int32
  • mut flags : Array[String]
  • date : String
  • body : Bytes
struct struct Summary
  • messages : Int32
  • recent : Int32
  • unseen : Int32
  • uidnext : Int32
  • uidvalidity : Int64
enum enum Value
  • Nil
  • Number(Int64)
  • Atom(String)
  • Text(Bytes)
  • List(Array[Value])
fn Value::list(Self) -> Array[Self]? fn Value::number(Self) -> Int64? fn Value::text(Self) -> String?
suberror suberror Refused
  • Malformed(String)
  • Exceeded(limit~ : Int32, got~ : Int32)
  • Order(String)
  • Unsupported(String)
A bright green bamboo grove 06
moonmail/pop3

Pick up and go

The small one: a greeting, a login, a list, and the messages themselves.

RFC 1939 RFC 2449 8 entries
value let limits : Limits
struct struct Client // private fields fn Client::apop(Self, String, String) -> Unit raise Refused fn Client::auth(Self, &@sasl.Mechanism) -> Unit raise Refused fn Client::capa(Self) -> Unit fn Client::capabilities(Self) -> Array[String] fn Client::dele(Self, Int32) -> Unit raise Refused fn Client::feed(Self, BytesView) -> Array[Event] raise Refused fn Client::has(Self, String) -> Bool fn Client::list(Self, message? : Int32) -> Unit raise Refused fn Client::new(limits? : Limits) -> Self fn Client::next_write(Self) -> Bytes? fn Client::noop(Self) -> Unit raise Refused fn Client::pass(Self, String) -> Unit raise Refused fn Client::pending(Self) -> Int32 fn Client::quit(Self) -> Unit fn Client::retr(Self, Int32) -> Unit raise Refused fn Client::rset(Self) -> Unit raise Refused fn Client::stat(Self) -> Unit raise Refused fn Client::state(Self) -> State fn Client::stls(Self) -> Unit raise Refused fn Client::top(Self, Int32, Int32) -> Unit raise Refused fn Client::uidl(Self, message? : Int32) -> Unit raise Refused fn Client::user(Self, String) -> Unit raise Refused
enum enum Command
  • Greeting
  • User(String)
  • Pass
  • Apop(String)
  • Auth(String)
  • Stls
  • Capa
  • Stat
  • List(Int32?)
  • Uidl(Int32?)
  • Retr(Int32)
  • Top(Int32, Int32)
  • Dele(Int32)
  • Rset
  • Noop
  • Quit
enum enum Event { Reply(Command, Reply); Sasl(@sasl.Refused) }
struct struct Limits { line : Int32; message : Int32 } fn Limits::new(line? : Int32, message? : Int32) -> Self
enum enum Reply
  • Greeting(text~ : String, timestamp~ : String?)
  • Ok(String)
  • Err(String)
  • Stat(count~ : Int32, size~ : Int64)
  • Listing(Array[(Int32, Int64)])
  • Uids(Array[(Int32, String)])
  • Content(Bytes)
  • Capabilities(Array[String])
enum enum State { Authorization; Transaction; Update }
suberror suberror Refused
  • Malformed(String)
  • Exceeded(limit~ : Int32, got~ : Int32)
  • Order(String)
  • Unsupported(String)
A green meadow under soft light 07
moonmail/jmap

The protocol that fits in a page

JMAP as documents: twenty-seven methods and the objects they carry, described once in moonmodel, and the check that a document is what it claims to be. No socket, which is how a browser can speak it.

RFC 8620 RFC 8621 no I/O 111 entries
fn fn address(String, parameters? : Map[String, String?]) -> @json.Json
fn fn address_model() -> @moonmodel.Model
fn fn after(String) -> @json.Json
fn fn all_in_thread_have_keyword(String) -> @json.Json
fn fn all_of(Array[@json.Json]) -> @json.Json
fn fn any_of(Array[@json.Json]) -> @json.Json
fn fn bcc_address(String) -> @json.Json
fn fn before(String) -> @json.Json
fn fn body_contains(String) -> @json.Json
fn fn body_structure(@json.Json) -> EmailBodyPart?
fn fn cc_address(String) -> @json.Json
fn fn child_of(String?) -> @json.Json
fn fn condition(Array[(String, @json.Json)]) -> @json.Json
fn fn created_id(Response, String, String) -> String raise Refused
fn fn delivery_status_model() -> @moonmodel.Model
fn fn discovery_url(String) -> String
fn fn email_address_group_model() -> @moonmodel.Model
fn fn email_address_model() -> @moonmodel.Model
fn fn email_body_of(@moonmail.Message) -> EmailBody
fn fn email_body_part_model() -> @moonmodel.Model
fn fn email_body_value_model() -> @moonmodel.Model
fn fn email_from_message(BytesView, mailbox_ids~ : Array[String], keywords? : Array[String], received_at? : String, blob_id? : String, thread_id? : String, id? : String) -> @json.Json raise Refused
fn fn email_header_model() -> @moonmodel.Model
fn fn email_ids(Response, String) -> Array[String] raise Refused
fn fn email_model() -> @moonmodel.Model
fn fn email_object(Response, String) -> @json.Json raise Refused
value let email_properties : Array[String]
fn fn email_submission_model() -> @moonmodel.Model
fn fn emails(Response, String) -> Array[Email] raise Refused
fn fn envelope(mail_from~ : @json.Json, rcpt_to~ : Array[@json.Json]) -> @json.Json
fn fn envelope_model() -> @moonmodel.Model
fn fn from_address(String) -> @json.Json
fn fn has_any_role() -> @json.Json
fn fn has_attachment() -> @json.Json
fn fn has_keyword(String) -> @json.Json
fn fn has_property(String, String) -> Bool
fn fn header_contains(name~ : String, value~ : String) -> @json.Json
fn fn identities(Response, String) -> Array[Identity] raise Refused
fn fn identity(String, String, signature? : String) -> @json.Json
fn fn identity_model() -> @moonmodel.Model
fn fn in_mailbox(String) -> @json.Json
fn fn in_mailbox_other_than(Array[String]) -> @json.Json
fn fn mailbox_ids(Response, String) -> Array[String] raise Refused
fn fn mailbox_model() -> @moonmodel.Model
fn fn mailbox_name_contains(String) -> @json.Json
fn fn mailbox_new(name~ : String, parent_id? : String, role? : String, sort_order? : Int32, is_subscribed? : Bool) -> @json.Json
value let mailbox_properties : Array[String]
fn fn mailbox_rights_model() -> @moonmodel.Model
fn fn mailboxes(Response, String) -> Array[Mailbox] raise Refused
fn fn max_size(Int32) -> @json.Json
fn fn method_names() -> Array[String]
fn fn min_size(Int32) -> @json.Json
fn fn model(String) -> @moonmodel.Model?
fn fn models() -> Array[@moonmodel.Model]
fn fn new_state(Response, String) -> String raise Refused
fn fn none_in_thread_have_keyword(String) -> @json.Json
fn fn none_of(Array[@json.Json]) -> @json.Json
fn fn not_created(Response, String, String) -> @json.Json? raise Refused
fn fn not_keyword(String) -> @json.Json
fn fn preview_of(@moonmail.Message) -> String
fn fn properties(String) -> Array[String]
fn fn request_error_model() -> @moonmodel.Model
fn fn resolve(String, String) -> String raise Refused
fn fn search_snippet_model() -> @moonmodel.Model
fn fn set_error_model() -> @moonmodel.Model
fn fn snippets(Response, String) -> Array[SearchSnippet] raise Refused
fn fn some_in_thread_have_keyword(String) -> @json.Json
fn fn subject_contains(String) -> @json.Json
fn fn submission_new(identity~ : String, email~ : String, envelope? : @json.Json, send_at? : String) -> @json.Json
fn fn submissions(Response, String) -> Array[EmailSubmission] raise Refused
fn fn subscribed() -> @json.Json
fn fn text_search(String) -> @json.Json
fn fn thread_model() -> @moonmodel.Model
fn fn threads(Response, String) -> Array[Thread] raise Refused
fn fn to_address(String) -> @json.Json
fn fn updated_ids(Response, String) -> Array[String] raise Refused
fn fn vacation_response(enabled~ : Bool, from_date? : String, to_date? : String, subject? : String, text_body? : String, html_body? : String) -> @json.Json
fn fn vacation_response_model() -> @moonmodel.Model
fn fn vacation_response_of(Response, String) -> VacationResponse? raise Refused
fn fn with_role(String) -> @json.Json
struct struct Address { email : String; parameters : Map[String, String] } fn Address::parse(@json.Json) -> Self
struct struct Call { name : String; args : @json.Json; tag : String }
struct struct Comparator { property : String; ascending : Bool; collation : String? } fn Comparator::new(property~ : String, ascending? : Bool, collation? : String) -> Self
struct struct DeliveryStatus { smtp_reply : String; delivered : String; displayed : String } fn DeliveryStatus::parse(@json.Json) -> Self
struct struct Draft
  • from : String?
  • to : Array[String]
  • cc : Array[String]
  • bcc : Array[String]
  • subject : String
  • text : String
fn Draft::new(to~ : Array[String], subject~ : String, text~ : String) -> Self
struct struct Email
  • id : String
  • subject : String
  • from : String?
  • received_at : String?
  • preview : String
  • unread : Bool
fn Email::parse(@json.Json) -> Self
struct struct EmailAddress { name : String?; email : String } fn EmailAddress::of_header(@moonmail.Mailbox) -> Self fn EmailAddress::parse(@json.Json) -> Self fn EmailAddress::to_string(Self) -> String
struct struct EmailBody
  • structure : EmailBodyPart
  • text : Array[EmailBodyPart]
  • html : Array[EmailBodyPart]
  • attachments : Array[EmailBodyPart]
struct struct EmailBodyPart
  • part_id : String?
  • blob_id : String?
  • size : Int32
  • headers : Array[EmailHeader]
  • name : String?
  • media_type : String
  • charset : String?
  • disposition : String?
  • cid : String?
  • language : Array[String]
  • location : String?
  • sub_parts : Array[EmailBodyPart]?
fn EmailBodyPart::leaves(Self) -> Array[Self] fn EmailBodyPart::parse(@json.Json) -> Self fn EmailBodyPart::to_json(Self) -> @json.Json
struct struct EmailBodyValue { value : String; encoding_problem : Bool; truncated : Bool } fn EmailBodyValue::parse(@json.Json) -> Self
struct struct EmailHeader { name : String; value : String } fn EmailHeader::parse(@json.Json) -> Self
struct struct EmailImport
  • blob_id : String
  • mailbox_ids : Array[String]
  • keywords : Array[String]
  • received_at : String?
fn EmailImport::new(blob_id~ : String, mailbox_ids~ : Array[String], keywords? : Array[String], received_at? : String) -> Self
struct struct EmailSubmission
  • id : String
  • identity_id : String
  • email_id : String
  • thread_id : String?
  • envelope : Envelope?
  • send_at : String?
  • undo_status : String
  • delivery : Map[String, DeliveryStatus]
fn EmailSubmission::parse(@json.Json) -> Self
struct struct Envelope { mail_from : Address; rcpt_to : Array[Address] } fn Envelope::parse(@json.Json) -> Self
struct struct Identity
  • id : String
  • name : String?
  • email : String
  • signature : String
  • may_delete : Bool
fn Identity::parse(@json.Json) -> Self
struct struct Invocation { name : String; args : @json.Json; tag : String }
enum enum Kind
  • Mailbox
  • Thread
  • Email
  • SearchSnippet
  • Identity
  • EmailSubmission
  • VacationResponse
fn Kind::capability(Self) -> String fn Kind::methods(Self) -> Array[String] fn Kind::name(Self) -> String
struct struct Mailbox
  • id : String
  • name : String
  • role : String?
  • parent_id : String?
  • total : Int32
  • unread : Int32
  • total_threads : Int32
  • unread_threads : Int32
  • sort_order : Int32
  • is_subscribed : Bool
  • rights : Rights?
fn Mailbox::parse(@json.Json) -> Self
struct struct Request { capabilities : Array[String]; calls : Array[Call] } fn Request::call(Self, String, @json.Json) -> String fn Request::changes(Self, String, Kind, since_state~ : String, max_changes? : Int32) -> String fn Request::copy(Self, from_account~ : String, account~ : String, kind~ : Kind, create~ : Map[String, @json.Json], if_from_in_state? : String, if_in_state? : String, on_success_destroy_original? : Bool, destroy_from_if_in_state? : String) -> String fn Request::echo(Self, @json.Json) -> String fn Request::email_destroy(Self, String, String) -> String fn Request::email_get(Self, String, Array[String], Array[String], body_properties? : Array[String], fetch_text_body_values? : Bool, fetch_html_body_values? : Bool, fetch_all_body_values? : Bool, max_body_value_bytes? : Int32) -> String fn Request::email_import(Self, String, Map[String, EmailImport], if_in_state? : String) -> String fn Request::email_mark_seen(Self, String, String, Bool) -> String fn Request::email_move(Self, String, String, String) -> String fn Request::email_parse(Self, String, Array[String], properties? : Array[String], body_properties? : Array[String], fetch_text_body_values? : Bool, fetch_html_body_values? : Bool, fetch_all_body_values? : Bool, max_body_value_bytes? : Int32) -> String fn Request::email_query(Self, String, String, Int32) -> String fn Request::email_query_changes(Self, String, since_query_state~ : String, filter? : @json.Json, sort? : Array[Comparator], max_changes? : Int32, up_to_id? : String, calculate_total? : Bool, collapse_threads? : Bool) -> String fn Request::email_query_filter(Self, String, filter? : @json.Json, sort? : Array[Comparator], position? : Int32, limit? : Int32, calculate_total? : Bool, collapse_threads? : Bool) -> String fn Request::email_set_draft(Self, String, String, Draft) -> String fn Request::email_set_update(Self, String, String, Array[(String, @json.Json)]) -> String fn Request::email_submission_cancel(Self, String, String) -> String fn Request::email_submission_set(Self, String, String, String, envelope? : @json.Json, send_at? : String, on_success_update_email? : @json.Json, on_success_destroy_email? : Bool) -> String fn Request::get(Self, String, Kind, ids? : Array[String], properties? : Array[String]) -> String fn Request::identity_get(Self, String, ids? : Array[String], properties? : Array[String]) -> String fn Request::identity_set(Self, String, create? : Map[String, @json.Json], update? : Map[String, @json.Json], destroy? : Array[String], if_in_state? : String) -> String fn Request::mailbox_get(Self, String, ids? : Array[String], properties? : Array[String]) -> String fn Request::mailbox_query(Self, String, filter? : @json.Json, sort? : Array[Comparator], position? : Int32, limit? : Int32, calculate_total? : Bool, sort_as_tree? : Bool, filter_as_tree? : Bool) -> String fn Request::mailbox_set(Self, String, create? : Map[String, @json.Json], update? : Map[String, @json.Json], destroy? : Array[String], if_in_state? : String, on_destroy_remove_emails? : Bool) -> String fn Request::new() -> Self fn Request::query(Self, String, Kind, filter? : @json.Json, sort? : Array[Comparator], position? : Int32, anchor? : String, anchor_offset? : Int32, limit? : Int32, calculate_total? : Bool) -> String fn Request::query_changes(Self, String, Kind, since_query_state~ : String, filter? : @json.Json, sort? : Array[Comparator], max_changes? : Int32, up_to_id? : String, calculate_total? : Bool) -> String fn Request::search_snippet_get(Self, String, Array[String], filter? : @json.Json) -> String fn Request::set(Self, String, Kind, create? : Map[String, @json.Json], update? : Map[String, @json.Json], destroy? : Array[String], if_in_state? : String) -> String fn Request::thread_get(Self, String, Array[String]) -> String fn Request::to_json(Self) -> @json.Json fn Request::to_string(Self) -> String fn Request::using_capability(Self, String) -> Unit fn Request::vacation_response_get(Self, String) -> String fn Request::vacation_response_set(Self, String, @json.Json, if_in_state? : String) -> String
struct struct Response { invocations : Array[Invocation]; session_state : String } fn Response::answer(Self, String) -> Invocation raise Refused fn Response::invocation(Self, String) -> Invocation? fn Response::parse(String) -> Self raise Refused
struct struct Rights
  • may_read_items : Bool
  • may_add_items : Bool
  • may_remove_items : Bool
  • may_set_seen : Bool
  • may_set_keywords : Bool
  • may_create_child : Bool
  • may_rename : Bool
  • may_delete : Bool
  • may_submit : Bool
struct struct SearchSnippet { email_id : String; subject : String?; preview : String? } fn SearchSnippet::parse(@json.Json) -> Self
struct struct Session
  • username : String?
  • account_id : String
  • api_url : String
  • download_url : String?
  • upload_url : String?
  • event_source_url : String?
  • state : String
fn Session::parse(String, String) -> Self raise Refused
struct struct Thread { id : String; email_ids : Array[String] } fn Thread::parse(@json.Json) -> Self
struct struct VacationResponse
  • id : String
  • enabled : Bool
  • from_date : String?
  • to_date : String?
  • subject : String?
  • text_body : String?
  • html_body : String?
fn VacationResponse::parse(@json.Json) -> Self
suberror suberror Refused
  • Malformed(at~ : String)
  • NotAnObject
  • Missing(name~ : String)
  • WrongType(name~ : String)
  • BadUrl(url~ : String)
  • Failed(call~ : String, kind~ : String, description~ : String)
fn fn all_objects(draft? : String) -> @json.Json
fn fn faults(String, @json.Json) -> Array[@moonschema.Fault] raise
fn fn schema(String, draft? : String) -> @json.Json raise
fn fn valid(String, @json.Json) -> Bool raise
suberror suberror Refused { Unknown(name~ : String) }

moonmail/jmap/validate

The descriptions turned into JSON Schema and run against a document.

fn fn all_objects(draft? : String) -> @json.Json
fn fn faults(String, @json.Json) -> Array[@moonschema.Fault] raise
fn fn schema(String, draft? : String) -> @json.Json raise
fn fn valid(String, @json.Json) -> Bool raise
suberror suberror Refused { Unknown(name~ : String) }
Clear blue sea and sky 08
moonmail/net

The one that touches a socket

The same state machines over TCP and TLS, including the upgrade to STARTTLS mid-conversation.

TCP TLS native only 6 entries
struct struct Imap // private fields async fn Imap::authenticate(Self, &@sasl.Mechanism) -> Unit fn Imap::client(Self) -> @imap.Client async fn Imap::connect(String, Security, port? : Int32, limits? : @imap.Limits, now? : Int64) -> Self async fn Imap::login(Self, String, String) -> Unit async fn Imap::logout(Self) -> Unit async fn Imap::read(Self) -> Array[@imap.Event] async fn Imap::run(Self) -> Array[@imap.Event] async fn Imap::wait(Self, Int32) -> Reply
struct struct Pop3 // private fields async fn Pop3::auth(Self, &@sasl.Mechanism) -> Unit fn Pop3::client(Self) -> @pop3.Client async fn Pop3::connect(String, Security, port? : Int32, limits? : @pop3.Limits, now? : Int64) -> Self async fn Pop3::list(Self) -> Array[(Int32, Int64)] async fn Pop3::login(Self, String, String) -> Unit async fn Pop3::quit(Self) -> Unit async fn Pop3::retr(Self, Int32) -> Bytes async fn Pop3::run(Self) -> Array[@pop3.Event]
struct struct Reply
  • data : Array[@imap.Response]
  • status : @imap.Status
  • code : @imap.Code?
  • text : String
enum enum Security { Tls(@tls.Client); StartTls(@tls.Client); Clear }
struct struct Smtp // private fields async fn Smtp::auth(Self, &@sasl.Mechanism) -> Unit fn Smtp::client(Self) -> @smtp.Client async fn Smtp::connect(String, Security, port? : Int32, hello? : String, lmtp? : Bool, limits? : @smtp.Limits, now? : Int64) -> Self async fn Smtp::quit(Self) -> Unit async fn Smtp::run(Self) -> Array[@smtp.Event] async fn Smtp::send(Self, String, Array[String], BytesView) -> Array[(String, @smtp.Reply)]
suberror suberror Rejected
  • Reply(@smtp.Command, @smtp.Reply)
  • Done(@imap.Status, @imap.Code?, String)
  • Err(@pop3.Command, String)
  • Sasl(@sasl.Refused)
  • Closed