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 to_owned(&self) -> MimePart<'static>

Obtain a version of self that has a static lifetime

Source

pub fn deep_conformance_check(&self) -> MessageConformance

Recursively performs deeper conformance checks on the message. At this time that includes attempting to decode any text parts into UTF-8 to see if they are correctly annotated, but it may include more checks in the future. The results of the deep checks are combined with any conformance issues detected during parsing, and returned.

Source

pub fn conformance(&self) -> MessageConformance

Returns the conformance flags determined during parsing

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 rfc2045_info(&self) -> Rfc2045Info

Source

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

Decode transfer decoding and return the body

Source

pub fn rebuild(&self, settings: Option<&CheckFixSettings>) -> 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, ) -> Result<()>

Source

pub fn replace_binary_body( &mut self, content_type: &str, content: &[u8], ) -> Result<()>

Source

pub fn new_no_transfer_encoding( content_type: &str, bytes: &[u8], ) -> Result<Self>

Source

pub fn new_text(content_type: &str, content: &str) -> Result<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) -> Result<Self>

Source

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

Source

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

Source

pub fn new_binary( content_type: &str, content: &[u8], options: Option<&AttachmentOptions>, ) -> Result<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.

Source

pub fn check_fix_conformance( &self, check: MessageConformance, fix: MessageConformance, settings: CheckFixSettings, ) -> Result<Option<Self>>

Trait Implementations§

Source§

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

Source§

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

Returns a duplicate 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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T