Skip to main content

MailApi

Trait MailApi 

Source
pub trait MailApi: Send {
    // Required methods
    fn list_mailboxes(
        &self,
    ) -> impl Future<Output = Result<Vec<Mailbox>, CoreError>> + Send;
    fn search(
        &self,
        query: &MailSearch,
    ) -> impl Future<Output = Result<MailHitPage, CoreError>> + Send;
    fn get_message(
        &self,
        id: &MessageId,
        offset: usize,
    ) -> impl Future<Output = Result<MailBody, CoreError>> + Send;
    fn get_attachment(
        &self,
        id: &MessageId,
        part: &str,
        offset: usize,
    ) -> impl Future<Output = Result<MailPart, CoreError>> + Send;
    fn create_draft(
        &self,
        draft: &Draft,
    ) -> impl Future<Output = Result<MessageId, CoreError>> + Send;
    fn send(
        &self,
        draft: &Draft,
    ) -> impl Future<Output = Result<SentMail, CoreError>> + Send;
    fn move_message(
        &self,
        id: &MessageId,
        destination: &MailDest,
    ) -> impl Future<Output = Result<(), CoreError>> + Send;
    fn set_flags(
        &self,
        id: &MessageId,
        flags: &FlagChange,
    ) -> impl Future<Output = Result<(), CoreError>> + Send;

    // Provided method
    fn get_attachment_bytes(
        &self,
        _id: &MessageId,
        _part: &str,
    ) -> impl Future<Output = Result<Attachment, CoreError>> + Send { ... }
}
Expand description

Mail backend for one account.

Required Methods§

Source

fn list_mailboxes( &self, ) -> impl Future<Output = Result<Vec<Mailbox>, CoreError>> + Send

Lists mailboxes.

§Errors

Returns CoreError when the mailbox list cannot be read.

Source

fn search( &self, query: &MailSearch, ) -> impl Future<Output = Result<MailHitPage, CoreError>> + Send

Searches messages.

§Errors

Returns CoreError when the search cannot be run.

Source

fn get_message( &self, id: &MessageId, offset: usize, ) -> impl Future<Output = Result<MailBody, CoreError>> + Send

Fetches one message. offset is a Unicode scalar index into the body.

§Errors

Returns CoreError when the message cannot be read.

Source

fn get_attachment( &self, id: &MessageId, part: &str, offset: usize, ) -> impl Future<Output = Result<MailPart, CoreError>> + Send

Fetches one attachment. offset is a Unicode scalar index into a text part.

§Errors

Returns CoreError when the part cannot be read.

Source

fn create_draft( &self, draft: &Draft, ) -> impl Future<Output = Result<MessageId, CoreError>> + Send

Appends a draft.

§Errors

Returns CoreError when the draft cannot be saved.

Source

fn send( &self, draft: &Draft, ) -> impl Future<Output = Result<SentMail, CoreError>> + Send

Sends a message. id: None means SMTP accepted it and the Sent copy failed.

§Errors

Returns CoreError when the message cannot be sent.

Source

fn move_message( &self, id: &MessageId, destination: &MailDest, ) -> impl Future<Output = Result<(), CoreError>> + Send

Moves a message.

§Errors

Returns CoreError when the move cannot be done.

Source

fn set_flags( &self, id: &MessageId, flags: &FlagChange, ) -> impl Future<Output = Result<(), CoreError>> + Send

Sets or clears flags.

§Errors

Returns CoreError when the flags cannot be stored.

Provided Methods§

Source

fn get_attachment_bytes( &self, _id: &MessageId, _part: &str, ) -> impl Future<Output = Result<Attachment, CoreError>> + Send

Fetches every decoded byte of one attachment, for saving to disk.

A backend that cannot do this keeps the default, which refuses.

§Errors

Returns CoreError when the part cannot be read.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§