Module imap_types::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
- A string subset to model IMAP’s
atom
s. - A string subset to model IMAP’s
1*ASTRING-CHAR
(“extendedatom
”). - A sequence of zero or more (non-null) bytes prefixed with a length.
- Either NIL or a string.
- A
Vec
that always contains >= 1 elements. - A quoted string.
- A quoted char.
- A short alphanumeric identifier.
- A human-readable text string used in some server responses.
Enums
- Either an (extended) atom or a string.
- A charset.
- Either a quoted string or a literal.
- Literal mode, i.e., sync or non-sync.