[−][src]Struct maildir::Maildir
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
).
Methods
impl Maildir
[src]
pub fn path(&self) -> &Path
[src]
Returns the path of the maildir base folder.
pub fn count_new(&self) -> usize
[src]
Returns the number of messages found inside the new
maildir folder.
pub fn count_cur(&self) -> usize
[src]
Returns the number of messages found inside the cur
maildir folder.
ⓘImportant traits for MailEntriespub fn list_new(&self) -> MailEntries
[src]
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.
ⓘImportant traits for MailEntriespub fn list_cur(&self) -> MailEntries
[src]
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.
pub fn move_new_to_cur(&self, id: &str) -> Result<()>
[src]
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
.
pub fn move_new_to_cur_with_flags(&self, id: &str, flags: &str) -> Result<()>
[src]
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.
pub fn find(&self, id: &str) -> Option<MailEntry>
[src]
Tries to find the message with the given id in the
maildir. This searches both the new
and the cur
folders.
pub fn set_flags(&self, id: &str, flags: &str) -> Result<()>
[src]
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.
pub fn add_flags(&self, id: &str, flags: &str) -> Result<()>
[src]
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.
pub fn remove_flags(&self, id: &str, flags: &str) -> Result<()>
[src]
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.
pub fn delete(&self, id: &str) -> Result<()>
[src]
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.
pub fn create_dirs(&self) -> Result<()>
[src]
Creates all neccessary directories if they don't exist yet. It is the library user's
responsibility to call this before using store_new
.
pub fn store_new(&self, data: &[u8]) -> Result<String, MaildirError>
[src]
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.
pub fn store_cur_with_flags(
&self,
data: &[u8],
flags: &str
) -> Result<String, MaildirError>
[src]
&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.
Trait Implementations
impl<'a> From<&'a str> for Maildir
[src]
impl From<PathBuf> for Maildir
[src]
impl From<String> for Maildir
[src]
Auto Trait Implementations
impl RefUnwindSafe for Maildir
impl Send for Maildir
impl Sync for Maildir
impl Unpin for Maildir
impl UnwindSafe for Maildir
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,