mailparsing

Struct MimePart

source
pub struct MimePart<'a> { /* private fields */ }

Implementations§

source§

impl<'a> MimePart<'a>

source

pub fn parse<S>(bytes: S) -> Result<Self>
where S: IntoSharedString<'a>,

Parse some data into a tree of MimeParts

source

pub fn conformance(&self) -> MessageConformance

source

pub fn child_parts(&self) -> &[Self]

Obtain a reference to the child parts

source

pub fn child_parts_mut(&mut self) -> &mut Vec<Self>

Obtain a mutable reference to the child parts

source

pub fn headers(&self) -> &HeaderMap<'_>

Obtains a reference to the headers

source

pub fn headers_mut<'b>(&'b mut self) -> &'b mut HeaderMap<'a>

Obtain a mutable reference to the headers

source

pub fn raw_body(&self) -> SharedString<'_>

Get the raw, transfer-encoded body

source

pub fn body(&self) -> Result<DecodedBody<'_>>

Decode transfer decoding and return the body

source

pub fn rebuild(&self) -> Result<Self>

Re-constitute the message. Each element will be parsed out, and the parsed form used to build a new message. This has the side effect of “fixing” non-conforming elements, but may come at the cost of “losing” the non-sensical or otherwise out of spec elements in the rebuilt message

source

pub fn write_message<W: Write>(&self, out: &mut W) -> Result<()>

Write the message content to the provided output stream

source

pub fn to_message_string(&self) -> String

Convenience method wrapping write_message that returns the formatted message as a standalone string

source

pub fn replace_text_body(&mut self, content_type: &str, content: &str)

source

pub fn new_text(content_type: &str, content: &str) -> Self

Constructs a new part with textual utf8 content. quoted-printable transfer encoding will be applied, unless it is smaller to represent the text in base64

source

pub fn new_text_plain(content: &str) -> Self

source

pub fn new_html(content: &str) -> Self

source

pub fn new_multipart( content_type: &str, parts: Vec<Self>, boundary: Option<&str>, ) -> Self

source

pub fn new_binary( content_type: &str, content: &[u8], options: Option<&AttachmentOptions>, ) -> Self

source

pub fn simplified_structure(&'a self) -> Result<SimplifiedStructure<'a>>

Returns a SimplifiedStructure representation of the mime tree, with the (probable) primary text/plain and text/html parts pulled out, and the remaining parts recorded as a flat attachments array

source

pub fn resolve_ptr(&self, ptr: PartPointer) -> Option<&Self>

Resolve a PartPointer to the corresponding MimePart

source

pub fn resolve_ptr_mut(&mut self, ptr: PartPointer) -> Option<&mut Self>

Resolve a PartPointer to the corresponding MimePart, for mutable access

source

pub fn simplified_structure_pointers( &self, ) -> Result<SimplifiedStructurePointers>

Returns a set of PartPointers that locate the (probable) primary text/plain and text/html parts, and the remaining parts recorded as a flat attachments array. The resulting PartPointers can be resolved to their actual instances for both immutable and mutable operations via resolve_ptr and resolve_ptr_mut.

Trait Implementations§

source§

impl<'a> Clone for MimePart<'a>

source§

fn clone(&self) -> MimePart<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for MimePart<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> PartialEq for MimePart<'a>

source§

fn eq(&self, other: &MimePart<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> StructuralPartialEq for MimePart<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for MimePart<'a>

§

impl<'a> RefUnwindSafe for MimePart<'a>

§

impl<'a> Send for MimePart<'a>

§

impl<'a> Sync for MimePart<'a>

§

impl<'a> Unpin for MimePart<'a>

§

impl<'a> UnwindSafe for MimePart<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V