Skip to main content

src/internal/encoder/encoding.gleam

//// Public types for the available encoders.
//// Available encodings.

/// The possible RFC's to follow when encoding a string using
/// QuotedPrintable.
pub type Rfc {
  Rfc2045
  Rfc2047
}

/// Field types as defined in RFC 822.
///
/// - `Unstructured`: Fields that contain text not further structured
///   (e.g., Subject, Comments).
/// - `Structured`: Fields that have a formally defined structure
///   (e.g., From, To, Date, Message-ID).
pub type FieldType {
  Unstructured
  Structured
}

/// Available encodings
pub type Encoding {
  Bit(Int)
  Base64
  PercentEncoding
  QuotedPrintable(Rfc)
  Text(FieldType)
}

/// Mode to use when encoding
pub type EncodingMode {
  Ascii
  Utf8
}

/// Errors which can be returned from the encoder functions
pub type EncoderError {
  InvalidCharacter(String)
  InvalidEmailAddress(String)
  InvalidDomain(String)
  MaximumSizeExceeded(Int)
  NoEncoderFound
  UnknownError
}