Skip to main content

ImapClientAsync

Trait ImapClientAsync 

Source
pub trait ImapClientAsync: Send {
Show 40 methods // Required method fn run<C, T, E>( &mut self, coroutine: C, ) -> impl Future<Output = Result<T, ImapClientError>> + Send where C: ImapCoroutine<Yield = ImapYield, Return = Result<T, E>> + Send, T: Send, E: Send, ImapClientError: From<E>; // Provided methods fn greeting( &mut self, ) -> impl Future<Output = Result<ImapGreetingOk, ImapClientError>> + Send { ... } fn starttls( &mut self, ) -> impl Future<Output = Result<Vec<u8>, ImapClientError>> + Send { ... } fn auth_anonymous( &mut self, message: Option<&str>, opts: ImapAuthAnonymousOptions, ) -> impl Future<Output = Result<Vec<Capability<'static>>, ImapClientError>> + Send { ... } fn auth_login( &mut self, user: &str, password: &str, opts: ImapAuthLoginOptions, ) -> impl Future<Output = Result<Vec<Capability<'static>>, ImapClientError>> + Send { ... } fn auth_plain( &mut self, authzid: Option<&str>, authcid: &str, password: &str, opts: ImapAuthPlainOptions, ) -> impl Future<Output = Result<Vec<Capability<'static>>, ImapClientError>> + Send { ... } fn auth_oauthbearer( &mut self, user: &str, host: &str, port: u16, token: &str, opts: ImapAuthOauthbearerOptions, ) -> impl Future<Output = Result<Vec<Capability<'static>>, ImapClientError>> + Send { ... } fn auth_xoauth2( &mut self, user: &str, token: &str, opts: ImapAuthXoauth2Options, ) -> impl Future<Output = Result<Vec<Capability<'static>>, ImapClientError>> + Send { ... } fn auth_scram_sha256( &mut self, creds: SaslScramCreds, opts: ImapAuthScramSha256Options, ) -> impl Future<Output = Result<Vec<Capability<'static>>, ImapClientError>> + Send { ... } fn logout( &mut self, ) -> impl Future<Output = Result<(), ImapClientError>> + Send { ... } fn capability( &mut self, ) -> impl Future<Output = Result<Vec<Capability<'static>>, ImapClientError>> + Send { ... } fn noop( &mut self, ) -> impl Future<Output = Result<(), ImapClientError>> + Send { ... } fn id( &mut self, opts: ImapServerIdOptions, ) -> impl Future<Output = Result<Option<Vec<(IString<'static>, NString<'static>)>>, ImapClientError>> + Send { ... } fn enable( &mut self, capabilities: Vec1<CapabilityEnable<'static>>, ) -> impl Future<Output = Result<Option<Vec<CapabilityEnable<'static>>>, ImapClientError>> + Send { ... } fn list( &mut self, reference: Mailbox<'static>, pattern: ListMailbox<'static>, ) -> impl Future<Output = Result<ImapMailboxListing, ImapClientError>> + Send { ... } fn lsub( &mut self, reference: Mailbox<'static>, pattern: ListMailbox<'static>, ) -> impl Future<Output = Result<ImapMailboxListing, ImapClientError>> + Send { ... } fn status( &mut self, mailbox: Mailbox<'static>, item_names: Cow<'static, [StatusDataItemName]>, ) -> impl Future<Output = Result<Vec<StatusDataItem>, ImapClientError>> + Send { ... } fn create( &mut self, mailbox: Mailbox<'static>, ) -> impl Future<Output = Result<(), ImapClientError>> + Send { ... } fn delete( &mut self, mailbox: Mailbox<'static>, ) -> impl Future<Output = Result<(), ImapClientError>> + Send { ... } fn rename( &mut self, from: Mailbox<'static>, to: Mailbox<'static>, ) -> impl Future<Output = Result<(), ImapClientError>> + Send { ... } fn subscribe( &mut self, mailbox: Mailbox<'static>, ) -> impl Future<Output = Result<(), ImapClientError>> + Send { ... } fn unsubscribe( &mut self, mailbox: Mailbox<'static>, ) -> impl Future<Output = Result<(), ImapClientError>> + Send { ... } fn select( &mut self, mailbox: Mailbox<'static>, opts: ImapMailboxSelectOptions, ) -> impl Future<Output = Result<ImapMailboxSelectData, ImapClientError>> + Send { ... } fn examine( &mut self, mailbox: Mailbox<'static>, opts: ImapMailboxExamineOptions, ) -> impl Future<Output = Result<ImapMailboxSelectData, ImapClientError>> + Send { ... } fn close( &mut self, ) -> impl Future<Output = Result<(), ImapClientError>> + Send { ... } fn unselect( &mut self, ) -> impl Future<Output = Result<(), ImapClientError>> + Send { ... } fn check( &mut self, ) -> impl Future<Output = Result<(), ImapClientError>> + Send { ... } fn expunge( &mut self, ) -> impl Future<Output = Result<Vec<NonZeroU32>, ImapClientError>> + Send { ... } fn uid_expunge( &mut self, sequence_set: SequenceSet, ) -> impl Future<Output = Result<Vec<NonZeroU32>, ImapClientError>> + Send { ... } fn fetch( &mut self, sequence_set: SequenceSet, items: MacroOrMessageDataItemNames<'static>, opts: ImapMessageFetchOptions, ) -> impl Future<Output = Result<BTreeMap<NonZeroU32, Vec1<MessageDataItem<'static>>>, ImapClientError>> + Send { ... } fn search( &mut self, criteria: Vec1<SearchKey<'static>>, opts: ImapMessageSearchOptions, ) -> impl Future<Output = Result<Vec<NonZeroU32>, ImapClientError>> + Send { ... } fn store( &mut self, sequence_set: SequenceSet, kind: StoreType, flags: Vec<Flag<'static>>, opts: ImapMessageStoreOptions, ) -> impl Future<Output = Result<BTreeMap<NonZeroU32, Vec1<MessageDataItem<'static>>>, ImapClientError>> + Send { ... } fn copy( &mut self, sequence_set: SequenceSet, mailbox: Mailbox<'static>, opts: ImapMessageCopyOptions, ) -> impl Future<Output = Result<ImapCopyUid, ImapClientError>> + Send { ... } fn move( &mut self, sequence_set: SequenceSet, mailbox: Mailbox<'static>, opts: ImapMessageMoveOptions, ) -> impl Future<Output = Result<ImapCopyUid, ImapClientError>> + Send { ... } fn append( &mut self, mailbox: Mailbox<'static>, message: &[u8], opts: ImapMessageAppendOptions, ) -> impl Future<Output = Result<ImapMessageAppendOutput, ImapClientError>> + Send { ... } fn sort( &mut self, sort_criteria: Vec1<SortCriterion>, search_criteria: Vec1<SearchKey<'static>>, opts: ImapMessageSortOptions, ) -> impl Future<Output = Result<Vec<NonZeroU32>, ImapClientError>> + Send { ... } fn thread( &mut self, algorithm: ThreadingAlgorithm<'static>, search_criteria: Vec1<SearchKey<'static>>, opts: ImapMessageThreadOptions, ) -> impl Future<Output = Result<Vec<Thread>, ImapClientError>> + Send { ... } fn login( &mut self, user: &str, password: &str, opts: ImapLoginOptions, ) -> impl Future<Output = Result<Vec<Capability<'static>>, ImapClientError>> + Send { ... } fn raw( &mut self, command: &[u8], ) -> impl Future<Output = Result<String, ImapClientError>> + Send { ... } fn select_qresync( &mut self, mailbox: Mailbox<'static>, uid_validity: NonZeroU32, highest_mod_seq: u64, capability: &[Capability<'static>], ) -> impl Future<Output = Result<ImapMailboxSelectData, ImapClientError>> + Send { ... }
}
Available on crate feature client only.
Expand description

Async IMAP command surface, the ImapClient twin for callers whose transport is a future.

Everything ImapClient documents applies here, plus the Send bounds. They are load-bearing rather than defensive: a plain async fn in a trait cannot promise that the future it returns is Send, so anything built from the default bodies would fail to compile under tokio::spawn, which is the first thing a worker-spawning consumer reaches for. Declaring the return type explicitly as impl Future<..> + Send, with Send as a supertrait so &mut Self carries through, keeps the defaults spawnable.

ImapClient deliberately carries no such bound. A blocking call returns a value, so there is no future whose auto-traits need pinning down, and requiring Send there would exclude a perfectly good client built on a thread-affine handle.

Required Methods§

Source

fn run<C, T, E>( &mut self, coroutine: C, ) -> impl Future<Output = Result<T, ImapClientError>> + Send
where C: ImapCoroutine<Yield = ImapYield, Return = Result<T, E>> + Send, T: Send, E: Send, ImapClientError: From<E>,

Runs a standard-shape coroutine to completion, fulfilling its read and write requests against the transport.

Provided Methods§

Source

fn greeting( &mut self, ) -> impl Future<Output = Result<ImapGreetingOk, ImapClientError>> + Send

Consumes the greeting and reports the advertised capabilities along with whether the session opened already authenticated.

Forces a CAPABILITY round-trip when the greeting carried none.

Source

fn starttls( &mut self, ) -> impl Future<Output = Result<Vec<u8>, ImapClientError>> + Send

STARTTLS. Caller still has to upgrade the socket and refresh capabilities.

Returns any bytes pre-read past the tagged response; a non-empty return is a STARTTLS-injection signal, refuse the upgrade. ImapSessionOpen does that refusal for you.

Source

fn auth_anonymous( &mut self, message: Option<&str>, opts: ImapAuthAnonymousOptions, ) -> impl Future<Output = Result<Vec<Capability<'static>>, ImapClientError>> + Send

SASL AUTHENTICATE ANONYMOUS.

Source

fn auth_login( &mut self, user: &str, password: &str, opts: ImapAuthLoginOptions, ) -> impl Future<Output = Result<Vec<Capability<'static>>, ImapClientError>> + Send

SASL AUTHENTICATE LOGIN (legacy). Prefer auth_plain or auth_scram_sha256 when supported.

Source

fn auth_plain( &mut self, authzid: Option<&str>, authcid: &str, password: &str, opts: ImapAuthPlainOptions, ) -> impl Future<Output = Result<Vec<Capability<'static>>, ImapClientError>> + Send

SASL AUTHENTICATE PLAIN.

Source

fn auth_oauthbearer( &mut self, user: &str, host: &str, port: u16, token: &str, opts: ImapAuthOauthbearerOptions, ) -> impl Future<Output = Result<Vec<Capability<'static>>, ImapClientError>> + Send

SASL AUTHENTICATE OAUTHBEARER. Channel must be TLS-protected.

Source

fn auth_xoauth2( &mut self, user: &str, token: &str, opts: ImapAuthXoauth2Options, ) -> impl Future<Output = Result<Vec<Capability<'static>>, ImapClientError>> + Send

SASL AUTHENTICATE XOAUTH2 (Google’s pre-standard mechanism). Prefer auth_oauthbearer when supported.

Source

fn auth_scram_sha256( &mut self, creds: SaslScramCreds, opts: ImapAuthScramSha256Options, ) -> impl Future<Output = Result<Vec<Capability<'static>>, ImapClientError>> + Send

Available on crate feature scram only.

SASL AUTHENTICATE SCRAM-SHA-256.

The credentials carry the client nonce, which RFC 5802 wants drawn from at least 18 bytes of cryptographic randomness, and the channel binding deciding whether the exchange announces SCRAM-SHA-256 or SCRAM-SHA-256-PLUS.

Source

fn logout(&mut self) -> impl Future<Output = Result<(), ImapClientError>> + Send

LOGOUT; ends the session.

Source

fn capability( &mut self, ) -> impl Future<Output = Result<Vec<Capability<'static>>, ImapClientError>> + Send

CAPABILITY; returns the advertised capabilities.

Source

fn noop(&mut self) -> impl Future<Output = Result<(), ImapClientError>> + Send

NOOP; round-trips to keep the connection alive or poll for updates.

Source

fn id( &mut self, opts: ImapServerIdOptions, ) -> impl Future<Output = Result<Option<Vec<(IString<'static>, NString<'static>)>>, ImapClientError>> + Send

ID. An opts.parameters of None sends ID NIL.

Source

fn enable( &mut self, capabilities: Vec1<CapabilityEnable<'static>>, ) -> impl Future<Output = Result<Option<Vec<CapabilityEnable<'static>>>, ImapClientError>> + Send

ENABLE; returns the capabilities the server confirmed enabling.

Source

fn list( &mut self, reference: Mailbox<'static>, pattern: ListMailbox<'static>, ) -> impl Future<Output = Result<ImapMailboxListing, ImapClientError>> + Send

LIST; returns the mailboxes matching reference and pattern.

Source

fn lsub( &mut self, reference: Mailbox<'static>, pattern: ListMailbox<'static>, ) -> impl Future<Output = Result<ImapMailboxListing, ImapClientError>> + Send

LSUB; returns the subscribed mailboxes matching reference and pattern.

Source

fn status( &mut self, mailbox: Mailbox<'static>, item_names: Cow<'static, [StatusDataItemName]>, ) -> impl Future<Output = Result<Vec<StatusDataItem>, ImapClientError>> + Send

STATUS; returns the requested status items for mailbox.

Source

fn create( &mut self, mailbox: Mailbox<'static>, ) -> impl Future<Output = Result<(), ImapClientError>> + Send

CREATE; creates mailbox.

Source

fn delete( &mut self, mailbox: Mailbox<'static>, ) -> impl Future<Output = Result<(), ImapClientError>> + Send

DELETE; deletes mailbox.

Source

fn rename( &mut self, from: Mailbox<'static>, to: Mailbox<'static>, ) -> impl Future<Output = Result<(), ImapClientError>> + Send

RENAME; renames mailbox from to to.

Source

fn subscribe( &mut self, mailbox: Mailbox<'static>, ) -> impl Future<Output = Result<(), ImapClientError>> + Send

SUBSCRIBE; subscribes to mailbox.

Source

fn unsubscribe( &mut self, mailbox: Mailbox<'static>, ) -> impl Future<Output = Result<(), ImapClientError>> + Send

UNSUBSCRIBE; unsubscribes from mailbox.

Source

fn select( &mut self, mailbox: Mailbox<'static>, opts: ImapMailboxSelectOptions, ) -> impl Future<Output = Result<ImapMailboxSelectData, ImapClientError>> + Send

SELECT; opens mailbox for read-write and returns its state.

Source

fn examine( &mut self, mailbox: Mailbox<'static>, opts: ImapMailboxExamineOptions, ) -> impl Future<Output = Result<ImapMailboxSelectData, ImapClientError>> + Send

EXAMINE; opens mailbox read-only and returns its state.

Source

fn close(&mut self) -> impl Future<Output = Result<(), ImapClientError>> + Send

CLOSE; expunges deleted messages and unselects the mailbox.

Source

fn unselect( &mut self, ) -> impl Future<Output = Result<(), ImapClientError>> + Send

UNSELECT; unselects the mailbox without expunging.

Source

fn check(&mut self) -> impl Future<Output = Result<(), ImapClientError>> + Send

CHECK; requests a mailbox checkpoint.

Source

fn expunge( &mut self, ) -> impl Future<Output = Result<Vec<NonZeroU32>, ImapClientError>> + Send

EXPUNGE; returns the expunged sequence numbers.

Source

fn uid_expunge( &mut self, sequence_set: SequenceSet, ) -> impl Future<Output = Result<Vec<NonZeroU32>, ImapClientError>> + Send

UID EXPUNGE <sequence_set> (RFC 4315); permanently removes only the \Deleted messages whose UID is in sequence_set, leaving any other \Deleted message untouched.

Requires the server to advertise UIDPLUS; returns the expunged sequence numbers.

Source

fn fetch( &mut self, sequence_set: SequenceSet, items: MacroOrMessageDataItemNames<'static>, opts: ImapMessageFetchOptions, ) -> impl Future<Output = Result<BTreeMap<NonZeroU32, Vec1<MessageDataItem<'static>>>, ImapClientError>> + Send

FETCH; returns the requested items keyed by message id.

Source

fn search( &mut self, criteria: Vec1<SearchKey<'static>>, opts: ImapMessageSearchOptions, ) -> impl Future<Output = Result<Vec<NonZeroU32>, ImapClientError>> + Send

SEARCH; returns the ids matching criteria.

Source

fn store( &mut self, sequence_set: SequenceSet, kind: StoreType, flags: Vec<Flag<'static>>, opts: ImapMessageStoreOptions, ) -> impl Future<Output = Result<BTreeMap<NonZeroU32, Vec1<MessageDataItem<'static>>>, ImapClientError>> + Send

STORE (echo variant); returns the server-reported FETCH echoes.

Source

fn copy( &mut self, sequence_set: SequenceSet, mailbox: Mailbox<'static>, opts: ImapMessageCopyOptions, ) -> impl Future<Output = Result<ImapCopyUid, ImapClientError>> + Send

COPY; copies messages to mailbox and returns the optional COPYUID pair.

Source

fn move( &mut self, sequence_set: SequenceSet, mailbox: Mailbox<'static>, opts: ImapMessageMoveOptions, ) -> impl Future<Output = Result<ImapCopyUid, ImapClientError>> + Send

MOVE; moves messages to mailbox and returns the optional COPYUID pair.

Source

fn append( &mut self, mailbox: Mailbox<'static>, message: &[u8], opts: ImapMessageAppendOptions, ) -> impl Future<Output = Result<ImapMessageAppendOutput, ImapClientError>> + Send

APPEND; returns the optional EXISTS count and APPENDUID pair.

Buffered: the whole message is held in memory. For large messages prefer the streaming APPEND coroutine.

Source

fn sort( &mut self, sort_criteria: Vec1<SortCriterion>, search_criteria: Vec1<SearchKey<'static>>, opts: ImapMessageSortOptions, ) -> impl Future<Output = Result<Vec<NonZeroU32>, ImapClientError>> + Send

SORT with a client-side fallback.

With opts.fallback == false this is a plain server SORT; with opts.fallback == true it SEARCHes, FETCHes the sort keys, and sorts locally. Feed fallback from a SORT capability check (the server SORT requires the extension).

Source

fn thread( &mut self, algorithm: ThreadingAlgorithm<'static>, search_criteria: Vec1<SearchKey<'static>>, opts: ImapMessageThreadOptions, ) -> impl Future<Output = Result<Vec<Thread>, ImapClientError>> + Send

THREAD; returns the message threads matching search_criteria.

Source

fn login( &mut self, user: &str, password: &str, opts: ImapLoginOptions, ) -> impl Future<Output = Result<Vec<Capability<'static>>, ImapClientError>> + Send

LOGIN. Channel must be TLS-protected.

Source

fn raw( &mut self, command: &[u8], ) -> impl Future<Output = Result<String, ImapClientError>> + Send

Sends one or more caller-tagged command lines byte-for-byte and returns the verbatim server response.

The bytes are written exactly as given (no tag is injected, no CRLF is trimmed or appended), so callers must tag every command and separate them with CRLF. The response spans up to and including the tagged completion of every command, which may arrive out of order.

Source

fn select_qresync( &mut self, mailbox: Mailbox<'static>, uid_validity: NonZeroU32, highest_mod_seq: u64, capability: &[Capability<'static>], ) -> impl Future<Output = Result<ImapMailboxSelectData, ImapClientError>> + Send

SELECT <mailbox> (QRESYNC ...).

Errors with QresyncNotSupported when capability lacks QRESYNC, with InvalidModSeq when highest_mod_seq is 0.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§