Module core

Source
Expand description

Core data types.

To ensure correctness and to support all forms of data transmission, imap-types uses types such as AString, Atom, IString, Quoted, and Literal. When constructing messages, imap-types can automatically choose the best representation. However, it’s always possible to manually select a specific representation.

The core types exist for two reasons. First, they guarantee that invalid messages cannot be produced. For example, a Tag will never contain whitespace as this would break parsing. Furthermore, the representation of a value may change the IMAP protocol flow. A username, for example, can be represented as an atom, a quoted string, or a literal. While atoms and quoted strings are similar, a literal requires a different protocol flow and implementations must take this into account.

While this seems complicated at first, there are good news: You don’t need to think about IMAP too much. imap-types ensures that everything you do is correct. If you are able to construct an invalid message, this is considered a bug in imap-types.

§Overview

       ┌───────┐ ┌─────────────────┐
       │AString│ │     NString     │
       └──┬─┬──┘ │(Option<IString>)│
          │ │    └─────┬───────────┘
          │ └──────┐   │
          │        │   │
┌────┐ ┌──▼────┐ ┌─▼───▼─┐
│Atom│ │AtomExt│ │IString│
└────┘ └───────┘ └┬─────┬┘
                  │     │
            ┌─────▼─┐ ┌─▼────┐
            │Literal│ │Quoted│
            └───────┘ └──────┘

Structs§

Atom
A string subset to model IMAP’s atoms.
AtomExt
A string subset to model IMAP’s 1*ASTRING-CHAR (“extended atom”).
Literal
A sequence of zero or more (non-null) bytes prefixed with a length.
NString
Either NIL or a string.
NonEmptyVec
A Vec that always contains >= 1 elements.
Quoted
A quoted string.
QuotedChar
A quoted char.
Tag
A short alphanumeric identifier.
Text
A human-readable text string used in some server responses.

Enums§

AString
Either an (extended) atom or a string.
Charset
A charset.
IString
Either a quoted string or a literal.
LiteralMode
Literal mode, i.e., sync or non-sync.