Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/core/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ impl<'x> Message<'x> {
.and_then(|a| a.as_address())
}

/// Returns all BCC header fields, permitted by [4.5.3 Obsolete Destination Address Fields](https://www.rfc-editor.org/info/rfc5322/#section-4.5.3)
pub fn all_bcc(&self) -> impl Iterator<Item = &Address<'x>> {
self.header_values(HeaderName::Bcc)
.filter_map(|a| a.as_address())
}

/// Returns the CC header field
pub fn cc(&self) -> Option<&Address<'x>> {
self.parts[0]
Expand All @@ -136,6 +142,12 @@ impl<'x> Message<'x> {
.and_then(|a| a.as_address())
}

/// Returns all CC header fields, permitted by [4.5.3 Obsolete Destination Address Fields](https://www.rfc-editor.org/info/rfc5322/#section-4.5.3)
pub fn all_cc(&self) -> impl Iterator<Item = &Address<'x>> {
self.header_values(HeaderName::Cc)
.filter_map(|a| a.as_address())
}

/// Returns all Comments header fields
pub fn comments(&self) -> &HeaderValue<'x> {
self.parts[0]
Expand Down Expand Up @@ -386,6 +398,12 @@ impl<'x> Message<'x> {
.and_then(|a| a.as_address())
}

/// Returns all To header fields, permitted by [4.5.3 Obsolete Destination Address Fields](https://www.rfc-editor.org/info/rfc5322/#section-4.5.3)
pub fn all_to(&self) -> impl Iterator<Item = &Address<'x>> {
self.header_values(HeaderName::To)
.filter_map(|a| a.as_address())
}

/// Returns a preview of the message body
pub fn body_preview(&self, preview_len: usize) -> Option<Cow<'x, str>> {
if !self.text_body.is_empty() {
Expand Down
Loading