[][src]Enum mail_chars::Charset

#[repr(u8)]
pub enum Charset {
    QTextWs,
    CTextWs,
    DTextWs,
    AText,
    RestrictedToken,
    Token,
    ObsNoWsCtl,
    Rfc7230Token,
}

An enum for the charsets represented through an internal lookup table.

Variants

QTextWs

qtext + ws, basically anything which can appear in a quoted string which is not a quoted-pair.

Note: this is equivalent to rfc7230 qdtext, excluding the obsolete part of the grammar. Note: the obsolete part of the grammar is excluded

rfc: 5322

CTextWs

ctext + ws

Note: the obsolete part of the grammar is excluded.

rfc: 5322

DTextWs

dtext + ws

rfc: 5322

AText

atext

rfc: 5322

RestrictedToken

Restricted-name-char subset of rfc2045 token with which IETF-tokens and IANA-tokens have to comply.

rfc: 6838 (related rfc2045)

Token

token

Note> there are multiple mail related definitions of token, this one is the rfc2045 based one.

rfc: 2045

ObsNoWsCtl

obs-NO-WS-CTL

rfc: 5322

combine with CText or QText to support the obsolete part of the grammar

Example

use mail_chars::{Charset, CharMatchExt, rfc5322};

fn is_ctext_with_obs(ch: char) -> bool {
    let res = Charset::lookup(ch);
    res.is(rfc5322::CTextWs) || res.is(rfc5322::ObsNoWsCtl)
}

assert!("\x01 comment \x02".chars().all(is_ctext_with_obs));
Rfc7230Token

token

rfc: 7230

Token as defined in rfc7230 (HTTP/1.1) not directly a mail grammar, but relevant for shared utilities like e.g. anything Media Type (i.e. MIME-Type/Content-Type) related.

Methods

impl Charset[src]

pub fn contains(&self, ch: char) -> bool[src]

Returns true if the char is part of this set of chars.

pub fn contains_or_non_ascii(&self, ch: char) -> bool[src]

Returns true if the char is part of the set of chars or not an ascii char.

This is mainly meant to be used in combination with rfc6532 which extends all *text grammar parts/character sets to contain any non-us-ascii character.

pub fn lookup(ch: char) -> LookupResult[src]

Uses the internal lookup table to classify a char.

Trait Implementations

impl Clone for Charset[src]

impl Copy for Charset[src]

impl Eq for Charset[src]

impl Ord for Charset[src]

impl PartialEq<Charset> for Charset[src]

impl PartialOrd<Charset> for Charset[src]

impl Debug for Charset[src]

impl Hash for Charset[src]

Auto Trait Implementations

impl Send for Charset

impl Sync for Charset

impl Unpin for Charset

impl UnwindSafe for Charset

impl RefUnwindSafe for Charset

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]