Skip to content

Commit b0a5925

Browse files
committed
v0.9.0
1 parent 4b5455c commit b0a5925

File tree

2 files changed

+85
-1
lines changed

2 files changed

+85
-1
lines changed

examples/custom_parser.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,14 @@ fn main() {
6666
.parse(MESSAGE)
6767
.unwrap();
6868

69-
// Parse only To, From, Date, and Subject headers
69+
// Parse only To, From, Date, and Subject headers. All other headers are parsed as raw.
7070
let _message = MessageParser::new()
7171
.with_mime_headers()
7272
.header_text(HeaderName::Subject)
7373
.header_address(HeaderName::From)
7474
.header_address(HeaderName::To)
7575
.header_date(HeaderName::Date)
76+
.default_header_raw()
7677
.parse(MESSAGE)
7778
.unwrap();
7879
}

src/core/header.rs

+83
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,89 @@ impl From<DateTime> for i64 {
10351035
}
10361036
}
10371037

1038+
impl TlsVersion {
1039+
pub fn as_str(&self) -> &'static str {
1040+
match self {
1041+
TlsVersion::SSLv2 => "SSLv2",
1042+
TlsVersion::SSLv3 => "SSLv3",
1043+
TlsVersion::TLSv1_0 => "TLSv1.0",
1044+
TlsVersion::TLSv1_1 => "TLSv1.1",
1045+
TlsVersion::TLSv1_2 => "TLSv1.2",
1046+
TlsVersion::TLSv1_3 => "TLSv1.3",
1047+
TlsVersion::DTLSv1_0 => "DTLSv1.0",
1048+
TlsVersion::DTLSv1_2 => "DTLSv1.2",
1049+
TlsVersion::DTLSv1_3 => "DTLSv1.3",
1050+
}
1051+
}
1052+
}
1053+
1054+
impl Greeting {
1055+
pub fn as_str(&self) -> &'static str {
1056+
match self {
1057+
Greeting::Helo => "HELO",
1058+
Greeting::Ehlo => "EHLO",
1059+
Greeting::Lhlo => "LHLO",
1060+
}
1061+
}
1062+
}
1063+
1064+
impl Protocol {
1065+
pub fn as_str(&self) -> &'static str {
1066+
match self {
1067+
Protocol::SMTP => "SMTP",
1068+
Protocol::LMTP => "LMTP",
1069+
Protocol::ESMTP => "ESMTP",
1070+
Protocol::ESMTPS => "ESMTPS",
1071+
Protocol::ESMTPA => "ESMTPA",
1072+
Protocol::ESMTPSA => "ESMTPSA",
1073+
Protocol::LMTPA => "LMTPA",
1074+
Protocol::LMTPS => "LMTPS",
1075+
Protocol::LMTPSA => "LMTPSA",
1076+
Protocol::UTF8SMTP => "UTF8SMTP",
1077+
Protocol::UTF8SMTPA => "UTF8SMTPA",
1078+
Protocol::UTF8SMTPS => "UTF8SMTPS",
1079+
Protocol::UTF8SMTPSA => "UTF8SMTPSA",
1080+
Protocol::UTF8LMTP => "UTF8LMTP",
1081+
Protocol::UTF8LMTPA => "UTF8LMTPA",
1082+
Protocol::UTF8LMTPS => "UTF8LMTPS",
1083+
Protocol::UTF8LMTPSA => "UTF8LMTPSA",
1084+
Protocol::HTTP => "HTTP",
1085+
Protocol::HTTPS => "HTTPS",
1086+
Protocol::IMAP => "IMAP",
1087+
Protocol::POP3 => "POP3",
1088+
Protocol::MMS => "MMS",
1089+
Protocol::Local => "Local",
1090+
}
1091+
}
1092+
}
1093+
1094+
impl Display for Host<'_> {
1095+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1096+
match self {
1097+
Host::Name(name) => name.fmt(f),
1098+
Host::IpAddr(ip) => ip.fmt(f),
1099+
}
1100+
}
1101+
}
1102+
1103+
impl Display for Protocol {
1104+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1105+
f.write_str(self.as_str())
1106+
}
1107+
}
1108+
1109+
impl Display for Greeting {
1110+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1111+
f.write_str(self.as_str())
1112+
}
1113+
}
1114+
1115+
impl Display for TlsVersion {
1116+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1117+
f.write_str(self.as_str())
1118+
}
1119+
}
1120+
10381121
impl Display for HeaderName<'_> {
10391122
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
10401123
write!(f, "{}", self.as_str())

0 commit comments

Comments
 (0)