diff --git a/src/address/types.rs b/src/address/types.rs index fb3b046..481ea2d 100644 --- a/src/address/types.rs +++ b/src/address/types.rs @@ -211,6 +211,7 @@ impl AsRef for Address { } #[derive(Debug, PartialEq, Clone, Copy)] +/// Errors in email addresses parsing pub enum AddressError { MissingParts, Unbalanced, diff --git a/src/message/header/content.rs b/src/message/header/content.rs index 1ca4cfb..774689c 100644 --- a/src/message/header/content.rs +++ b/src/message/header/content.rs @@ -7,7 +7,10 @@ use std::{ str::{from_utf8, FromStr}, }; -header! { (ContentId, "Content-ID") => [String] } +header! { + /// `Content-Id` header, defined in [RFC2045](https://tools.ietf.org/html/rfc2045#section-7) + (ContentId, "Content-ID") => [String] +} /// `Content-Transfer-Encoding` of the body /// diff --git a/src/message/header/mod.rs b/src/message/header/mod.rs index c0b2deb..e7f4ca2 100644 --- a/src/message/header/mod.rs +++ b/src/message/header/mod.rs @@ -1,8 +1,4 @@ -/*! - -## Headers widely used in email messages - -*/ +//! Headers widely used in email messages mod content; mod mailbox; diff --git a/src/message/header/special.rs b/src/message/header/special.rs index fbb8d5d..4614440 100644 --- a/src/message/header/special.rs +++ b/src/message/header/special.rs @@ -5,6 +5,7 @@ use hyperx::{ use std::{fmt::Result as FmtResult, str::from_utf8}; #[derive(Debug, Clone, Copy, PartialEq)] +/// Message format version, defined in [RFC2045](https://tools.ietf.org/html/rfc2045#section-4) pub struct MimeVersion { pub major: u8, pub minor: u8, diff --git a/src/message/header/textual.rs b/src/message/header/textual.rs index ba14141..586d0c5 100644 --- a/src/message/header/textual.rs +++ b/src/message/header/textual.rs @@ -6,8 +6,9 @@ use hyperx::{ use std::{fmt::Result as FmtResult, str::from_utf8}; macro_rules! text_header { - ( $type_name: ident, $header_name: expr ) => { + ($(#[$attr:meta])* Header($type_name: ident, $header_name: expr )) => { #[derive(Debug, Clone, PartialEq)] + $(#[$attr])* pub struct $type_name(pub String); impl Header for $type_name { @@ -33,13 +34,41 @@ macro_rules! text_header { }; } -text_header!(Subject, "Subject"); -text_header!(Comments, "Comments"); -text_header!(Keywords, "Keywords"); -text_header!(InReplyTo, "In-Reply-To"); -text_header!(References, "References"); -text_header!(MessageId, "Message-Id"); -text_header!(UserAgent, "User-Agent"); +text_header!( + /// `Subject` of the message, defined in [RFC5322](https://tools.ietf.org/html/rfc5322#section-3.6.5) + Header(Subject, "Subject") +); +text_header!( + /// `Comments` of the message, defined in [RFC5322](https://tools.ietf.org/html/rfc5322#section-3.6.5) + Header(Comments, "Comments") +); +text_header!( + /// `Keywords` header. Should contain a comma-separated list of one or more + /// words or quoted-strings, defined in [RFC5322](https://tools.ietf.org/html/rfc5322#section-3.6.5) + Header(Keywords, "Keywords") +); +text_header!( + /// `In-Reply-To` header. Contains one or more + /// unique message identifiers, + /// defined in [RFC5322](https://tools.ietf.org/html/rfc5322#section-3.6.4) + Header(InReplyTo, "In-Reply-To") +); +text_header!( + /// `References` header. Contains one or more + /// unique message identifiers, + /// defined in [RFC5322](https://tools.ietf.org/html/rfc5322#section-3.6.4) + Header(References, "References") +); +text_header!( + /// `Message-Id` header. Contains a unique message identifier, + /// defined in [RFC5322](https://tools.ietf.org/html/rfc5322#section-3.6.4) + Header(MessageId, "Message-Id") +); +text_header!( + /// `User-Agent` header. Contains information about the client, + /// defined in [draft-melnikov-email-user-agent-00](https://tools.ietf.org/html/draft-melnikov-email-user-agent-00#section-3) + Header(UserAgent, "User-Agent") +); fn parse_text(raw: &[u8]) -> HyperResult { if let Ok(src) = from_utf8(raw) { diff --git a/src/message/mod.rs b/src/message/mod.rs index 0ca9e5d..cfb0953 100644 --- a/src/message/mod.rs +++ b/src/message/mod.rs @@ -332,7 +332,7 @@ impl MessageBuilder { /// Set `Sender` header. Should be used when providing several `From` mailboxes. /// - /// https://tools.ietf.org/html/rfc5322#section-3.6.2 + /// Defined in [RFC5322](https://tools.ietf.org/html/rfc5322#section-3.6.2). /// /// Shortcut for `self.header(header::Sender(mbox))`. pub fn sender(self, mbox: Mailbox) -> Self { @@ -341,7 +341,7 @@ impl MessageBuilder { /// Set or add mailbox to `From` header /// - /// https://tools.ietf.org/html/rfc5322#section-3.6.2 + /// Defined in [RFC5322](https://tools.ietf.org/html/rfc5322#section-3.6.2). /// /// Shortcut for `self.mailbox(header::From(mbox))`. pub fn from(self, mbox: Mailbox) -> Self { @@ -350,7 +350,7 @@ impl MessageBuilder { /// Set or add mailbox to `ReplyTo` header /// - /// https://tools.ietf.org/html/rfc5322#section-3.6.2 + /// Defined in [RFC5322](https://tools.ietf.org/html/rfc5322#section-3.6.2). /// /// Shortcut for `self.mailbox(header::ReplyTo(mbox))`. pub fn reply_to(self, mbox: Mailbox) -> Self { diff --git a/src/transport/smtp/authentication.rs b/src/transport/smtp/authentication.rs index d02f50c..37f8f7c 100644 --- a/src/transport/smtp/authentication.rs +++ b/src/transport/smtp/authentication.rs @@ -39,15 +39,16 @@ where #[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Mechanism { - /// PLAIN authentication mechanism - /// RFC 4616: https://tools.ietf.org/html/rfc4616 + /// PLAIN authentication mechanism, defined in + /// [RFC 4616](https://tools.ietf.org/html/rfc4616) Plain, /// LOGIN authentication mechanism /// Obsolete but needed for some providers (like office365) - /// https://www.ietf.org/archive/id/draft-murchison-sasl-login-00.txt + /// + /// Defined in [draft-murchison-sasl-login-00](https://www.ietf.org/archive/id/draft-murchison-sasl-login-00.txt). Login, - /// Non-standard XOAUTH2 mechanism - /// https://developers.google.com/gmail/imap/xoauth2-protocol + /// Non-standard XOAUTH2 mechanism, defined in + /// [xoauth2-protocol](https://developers.google.com/gmail/imap/xoauth2-protocol) Xoauth2, } diff --git a/src/transport/smtp/extension.rs b/src/transport/smtp/extension.rs index fdd52a2..66372cc 100644 --- a/src/transport/smtp/extension.rs +++ b/src/transport/smtp/extension.rs @@ -71,15 +71,15 @@ impl ClientId { pub enum Extension { /// 8BITMIME keyword /// - /// RFC 6152: https://tools.ietf.org/html/rfc6152 + /// Defined in [RFC 6152](https://tools.ietf.org/html/rfc6152) EightBitMime, /// SMTPUTF8 keyword /// - /// RFC 6531: https://tools.ietf.org/html/rfc6531 + /// Defined in [RFC 6531](https://tools.ietf.org/html/rfc6531) SmtpUtfEight, /// STARTTLS keyword /// - /// RFC 2487: https://tools.ietf.org/html/rfc2487 + /// Defined in [RFC 2487](https://tools.ietf.org/html/rfc2487) StartTls, /// AUTH mechanism Authentication(Mechanism), diff --git a/src/transport/smtp/mod.rs b/src/transport/smtp/mod.rs index aa4dff8..63f75d0 100644 --- a/src/transport/smtp/mod.rs +++ b/src/transport/smtp/mod.rs @@ -168,7 +168,7 @@ pub const SMTP_PORT: u16 = 25; pub const SUBMISSION_PORT: u16 = 587; /// Default submission over TLS port /// -/// https://tools.ietf.org/html/rfc8314 +/// Defined in [RFC8314](https://tools.ietf.org/html/rfc8314) pub const SUBMISSIONS_PORT: u16 = 465; /// Default timeout