maildir

Struct Maildir

source
pub struct Maildir { /* private fields */ }
Expand description

The main entry point for this library. This struct can be instantiated from a path using the from implementations. The path passed in to the from should be the root of the maildir (the folder containing cur, new, and tmp).

Implementations§

source§

impl Maildir

source

pub fn with_path<P: Into<PathBuf>>(p: P) -> Self

Create a Maildir from a path-compatible parameter

source

pub fn set_dir_mode(&mut self, dir_mode: Option<u32>)

Set the directory permission mode. By default this is left unspecified, which causes directories to be created with permissions suitable for the owner, obeying the standard unix umask semantics. If you choose to assign the permission modes here, the umask will be ignored and the explicit modes that you set will be used on any directories that are created by Maildir. This will NOT change modes on existing directories they will only be applied to directores created by this instance of Maildir

source

pub fn set_file_mode(&mut self, file_mode: Option<u32>)

Set the file permission mode. By default this is left unspecified, which causes files to be created with permissions suitable for the owner, obeying the standard unix umask semantics. If you choose to assign the permission modes here, the umask will be ignored and the explicit modes that you set will be used on any files that are created by Maildir. This will NOT change modes on existing files they will only be applied to files created by this instance of Maildir

source

pub fn path(&self) -> &Path

Returns the path of the maildir base folder.

source

pub fn count_new(&self) -> usize

Returns the number of messages found inside the new maildir folder.

source

pub fn count_cur(&self) -> usize

Returns the number of messages found inside the cur maildir folder.

source

pub fn list_new(&self) -> MailEntries

Returns an iterator over the messages inside the new maildir folder. The order of messages in the iterator is not specified, and is not guaranteed to be stable over multiple invocations of this method.

source

pub fn list_cur(&self) -> MailEntries

Returns an iterator over the messages inside the cur maildir folder. The order of messages in the iterator is not specified, and is not guaranteed to be stable over multiple invocations of this method.

source

pub fn list_subdirs(&self) -> MaildirEntries

Returns an iterator over the maildir subdirectories. The order of subdirectories in the iterator is not specified, and is not guaranteed to be stable over multiple invocations of this method.

source

pub fn move_new_to_cur(&self, id: &str) -> Result<()>

Moves a message from the new maildir folder to the cur maildir folder. The id passed in should be obtained from the iterator produced by list_new.

source

pub fn move_new_to_cur_with_flags(&self, id: &str, flags: &str) -> Result<()>

Moves a message from the new maildir folder to the cur maildir folder, and sets the given flags. The id passed in should be obtained from the iterator produced by list_new.

The possible flags are described e.g. at https://cr.yp.to/proto/maildir.html or http://www.courier-mta.org/maildir.html.

source

pub fn copy_to(&self, id: &str, target: &Maildir) -> Result<()>

Copies a message from the current maildir to the targetted maildir.

source

pub fn move_to(&self, id: &str, target: &Maildir) -> Result<()>

Moves a message from the current maildir to the targetted maildir.

source

pub fn find(&self, id: &str) -> Option<MailEntry>

Tries to find the message with the given id in the maildir. This searches both the new and the cur folders.

source

pub fn set_flags(&self, id: &str, flags: &str) -> Result<()>

Updates the flags for the message with the given id in the maildir. This only searches the cur folder, because that’s the folder where messages have flags. Returns an error if the message was not found. All existing flags are overwritten with the new flags provided.

source

pub fn add_flags(&self, id: &str, flags: &str) -> Result<()>

Adds the given flags to the message with the given id in the maildir. This only searches the cur folder, because that’s the folder where messages have flags. Returns an error if the message was not found. Flags are deduplicated, so setting a already-set flag has no effect.

source

pub fn remove_flags(&self, id: &str, flags: &str) -> Result<()>

Removes the given flags to the message with the given id in the maildir. This only searches the cur folder, because that’s the folder where messages have flags. Returns an error if the message was not found. If the message doesn’t have the flag(s) to be removed, those flags are ignored.

source

pub fn delete(&self, id: &str) -> Result<()>

Deletes the message with the given id in the maildir. This searches both the new and the cur folders, and deletes the file from the filesystem. Returns an error if no message was found with the given id.

source

pub fn create_dirs(&self) -> Result<()>

Creates all neccessary directories if they don’t exist yet. It is the library user’s responsibility to call this before using store_new.

source

pub fn store_new(&self, data: &[u8]) -> Result<String, MaildirError>

Stores the given message data as a new message file in the Maildir new folder. Does not create the neccessary directories, so if in doubt call create_dirs before using store_new. Returns the Id of the inserted message on success.

source

pub fn store_cur_with_flags( &self, data: &[u8], flags: &str, ) -> Result<String, MaildirError>

Stores the given message data as a new message file in the Maildir cur folder, adding the given flags to it. The possible flags are explained e.g. at https://cr.yp.to/proto/maildir.html or http://www.courier-mta.org/maildir.html. Returns the Id of the inserted message on success.

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

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

§

fn vzip(self) -> V