#[repr(u8)]pub enum Charset {
QTextWs = 8,
CTextWs = 1,
DTextWs = 2,
AText = 4,
RestrictedToken = 16,
Token = 32,
ObsNoWsCtl = 64,
Rfc7230Token = 128,
}Expand description
An enum for the charsets represented through an internal lookup table.
Variants§
QTextWs = 8
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 = 1
ctext + ws
Note: the obsolete part of the grammar is excluded.
rfc: 5322
DTextWs = 2
dtext + ws
rfc: 5322
AText = 4
atext
rfc: 5322
RestrictedToken = 16
Restricted-name-char subset of rfc2045 token with which IETF-tokens and IANA-tokens have to comply.
rfc: 6838 (related rfc2045)
Token = 32
token
Note> there are multiple mail related definitions of token, this one is the rfc2045 based one.
rfc: 2045
ObsNoWsCtl = 64
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 = 128
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.
Implementations§
Source§impl Charset
impl Charset
Sourcepub fn contains(&self, ch: char) -> bool
pub fn contains(&self, ch: char) -> bool
Returns true if the char is part of this set of chars.
Sourcepub fn contains_or_non_ascii(&self, ch: char) -> bool
pub fn contains_or_non_ascii(&self, ch: char) -> bool
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.
Sourcepub fn lookup(ch: char) -> LookupResult
pub fn lookup(ch: char) -> LookupResult
Uses the internal lookup table to classify a char.