Skip to main content

ProtonClient

Struct ProtonClient 

Source
pub struct ProtonClient<M = ReadOnly> { /* private fields */ }
Expand description

IMAP client for Proton Mail via Proton Bridge.

The type parameter M controls which operations are available:

MRead opsWrite ops
ReadOnlyyesno
ReadWriteyesyes

Implementations§

Source§

impl<M> ProtonClient<M>

Source

pub const fn new(config: ImapConfig) -> Self

Source§

impl<M: Send + Sync> ProtonClient<M>

Source

pub async fn list_folders(&self) -> Result<Vec<String>>

List all available IMAP folders.

§Errors

Returns an error if the connection or LIST command fails.

Source

pub async fn fetch_uid(&self, folder: &Folder, uid: u32) -> Result<Email>

Fetch a single email by UID from a folder.

§Errors

Returns an error if the connection, SELECT, or FETCH fails, or if the message body cannot be parsed.

Source

pub async fn fetch_unseen(&self, folder: &Folder) -> Result<Vec<Email>>

Fetch all unseen emails from a folder.

§Errors

Returns an error if the connection, SELECT, or SEARCH fails.

Source

pub async fn fetch_all(&self, folder: &Folder) -> Result<Vec<Email>>

Fetch all emails from a folder.

§Errors

Returns an error if the connection, SELECT, or SEARCH fails.

Source

pub async fn fetch_last_n( &self, folder: &Folder, n: usize, ) -> Result<Vec<Email>>

Fetch the N most recent emails from a folder.

§Errors

Returns an error if the connection, SELECT, SEARCH, or FETCH fails.

Source

pub async fn fetch_date_range( &self, folder: &Folder, since: NaiveDate, before: NaiveDate, ) -> Result<Vec<Email>>

Fetch emails within a date range from a folder.

IMAP semantics: SINCE >= date, BEFORE < date.

§Errors

Returns an error if the connection, SELECT, or SEARCH fails.

Source

pub async fn search(&self, folder: &Folder, query: &str) -> Result<Vec<Email>>

Search emails using an arbitrary IMAP search query.

§Errors

Returns an error if the connection, SELECT, or SEARCH fails.

Source§

impl ProtonClient<ReadWrite>

Source

pub async fn move_to_folder( &self, uid: u32, from: &Folder, to: &Folder, ) -> Result<()>

Move an email from one folder to another.

Selects from, copies the message to to, marks it \Deleted in the source folder, and expunges.

§Errors

Returns an error if any IMAP command fails.

Source

pub async fn add_flag( &self, uid: u32, folder: &Folder, flag: &Flag, ) -> Result<()>

Add a flag to an email.

§Errors

Returns an error if the connection, SELECT, or STORE fails.

Source

pub async fn remove_flag( &self, uid: u32, folder: &Folder, flag: &Flag, ) -> Result<()>

Remove a flag from an email.

§Errors

Returns an error if the connection, SELECT, or STORE fails.

Source

pub async fn archive(&self, uid: u32, from: &Folder) -> Result<()>

Archive an email by moving it to the Archive folder.

§Errors

Returns an error if the move operation fails.

Source

pub async fn unmark_all_read(&self, folder: &Folder) -> Result<()>

Remove the \Seen flag from all messages in a folder.

§Errors

Returns an error if the connection, SELECT, SEARCH, or STORE fails.

Auto Trait Implementations§

§

impl<M> Freeze for ProtonClient<M>

§

impl<M> RefUnwindSafe for ProtonClient<M>
where M: RefUnwindSafe,

§

impl<M> Send for ProtonClient<M>
where M: Send,

§

impl<M> Sync for ProtonClient<M>
where M: Sync,

§

impl<M> Unpin for ProtonClient<M>
where M: Unpin,

§

impl<M> UnwindSafe for ProtonClient<M>
where M: UnwindSafe,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more