MailEntry

Struct MailEntry 

Source
pub struct MailEntry { /* private fields */ }
Expand description

A struct representing a single email message inside the maildir.

No parsing is done. This struct only holds the path to the message file, and handles file system operations. The struct can only be created by methods in Maildir.

Implementations§

Source§

impl MailEntry

Source

pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self, Error>

Create a new MailEntry from a path.

§Errors

Will error if the path does not contain a file name part.

Source

pub fn id(&self) -> &str

Get the unique identifier of the email message.

Source

pub fn set_id<S: ToString>(&mut self, id: S) -> Result<(), Error>

Set the unique identifier of the email message.

This also updates the path to the email message and renames the file on the file system.

§Errors

This method will return an error if the new ID is invalid or if there was an error renaming the file on the file system.

Source

pub fn path(&self) -> &Path

Get the path to the email message.

Source

pub fn to_path_buf(self) -> PathBuf

Takes ownership of the MailEntry and returns the base PathBuf

Source

pub fn move_to_new(&mut self) -> Result<(), Error>

Moves the email message to the new directory.

Source

pub fn move_to_cur(&mut self) -> Result<(), Error>

Moves the email message to the cur directory.

Source

pub fn move_to_tmp(&mut self) -> Result<(), Error>

Moves the email message to the tmp directory.

Source

pub fn flags(&self) -> impl Iterator<Item = &Flag>

Get the flags of the email message.

Source

pub fn flags_to_string(&self) -> String

Get the flags of the email message as a string.

Source

pub fn set_flag(&mut self, flag: Flag) -> Result<(), Error>

Set a flag on the email message.

This also updates the path to the email message and renames the file on the file system.

§Errors

This method will return an error if there was an error renaming the file.

Source

pub fn unset_flag(&mut self, flag: Flag) -> Result<(), Error>

Unset a flag on the email message.

This also updates the path to the email message and renames the file on the file system.

§Errors

This method will return an error if there was an error renaming the file.

Source

pub fn has_flag(&self, flag: Flag) -> bool

Returns true if the email message has the supplied flag

Source

pub fn to_bytes(&self) -> Result<Vec<u8>>

Get the raw bytes of the email message.

§Errors

This method will return an error if the email message could not be read from the file system. This could be because the path does not exists, or if there was another read error (e.g. permission denied.)

Trait Implementations§

Source§

impl Debug for MailEntry

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> 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, 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.