Skip to main content

EmailClientStd

Struct EmailClientStd 

Source
pub struct EmailClientStd {
    pub imap: Option<ImapClientStd>,
    pub jmap: Option<JmapClientStd>,
    pub smtp: Option<SmtpClientStd>,
    pub maildir: Option<MaildirClient>,
    pub m2dir: Option<M2dirClient>,
}
Available on crate feature client and (crate features imap or jmap or m2dir or maildir or smtp) only.
Expand description

Std-blocking multi-protocol email client.

Each slot holds an optional per-protocol client. Empty by default; register backends through the with_<protocol> builders or the connect_<protocol> convenience helpers. Slots are pub so callers can read the registered client back out (e.g. to tweak its pub knobs after construction).

Fields§

§imap: Option<ImapClientStd>
Available on crate feature imap only.
§jmap: Option<JmapClientStd>
Available on crate feature jmap only.
§smtp: Option<SmtpClientStd>
Available on crate feature smtp only.
§maildir: Option<MaildirClient>
Available on crate feature maildir only.
§m2dir: Option<M2dirClient>
Available on crate feature m2dir only.

Implementations§

Source§

impl EmailClientStd

Source

pub fn new() -> Self

Builds an empty client with no backend registered.

Source

pub fn with_imap(self, client: ImapClientStd) -> Self

Available on crate feature imap only.

Registers the IMAP backend.

Source

pub fn with_jmap(self, client: JmapClientStd) -> Self

Available on crate feature jmap only.

Registers the JMAP backend.

Source

pub fn with_smtp(self, client: SmtpClientStd) -> Self

Available on crate feature smtp only.

Registers the SMTP backend.

Source

pub fn with_maildir(self, client: MaildirClient) -> Self

Available on crate feature maildir only.

Registers the Maildir backend.

Source

pub fn with_m2dir(self, client: M2dirClient) -> Self

Available on crate feature m2dir only.

Registers the m2dir backend.

Source

pub fn connect_imap( self, url: &Url, tls: &Tls, starttls: bool, sasl: Option<impl Into<ImapSasl>>, auto_id: Option<Vec<(IString<'static>, NString<'static>)>>, ) -> Result<Self, EmailClientStdError>

Available on crate feature imap and (crate features native-tls or rustls-aws or rustls-ring) only.

Opens an IMAP connection via ImapClientStd::connect and registers the resulting client. See ImapClientStd::connect for the auto_id semantics.

Source

pub fn connect_jmap( self, url: &Url, tls: &Tls, http_auth: SecretString, ) -> Result<Self, EmailClientStdError>

Available on crate feature jmap and (crate features native-tls or rustls-aws or rustls-ring) only.

Opens a JMAP connection via JmapClientStd::connect and registers the resulting client (session already discovered).

Source

pub fn connect_smtp( self, url: &Url, tls: &Tls, starttls: bool, domain: EhloDomain<'_>, sasl: Option<impl Into<Sasl>>, ) -> Result<Self, EmailClientStdError>

Available on crate feature smtp and (crate features native-tls or rustls-aws or rustls-ring) only.

Opens an SMTP connection via SmtpClientStd::connect and registers the resulting client.

Source

pub fn ping(&mut self) -> Result<(), EmailClientStdError>

Pings every registered network backend (IMAP, SMTP) to reset the server’s inactivity timer on long-idle sessions. Storage backends (Maildir, M2dir) and JMAP (HTTP, stateless) have nothing to keep alive and are skipped. Returns the first error encountered, or Ok(()) when every registered network backend acknowledged the NOOP.

Source

pub fn list_mailboxes( &mut self, with_counts: bool, ) -> Result<Vec<Mailbox>, EmailClientStdError>

Lists every visible mailbox via the highest-priority registered storage backend.

Source

pub fn list_envelopes( &mut self, mailbox: &str, page: Option<u32>, page_size: Option<u32>, with_attachment: bool, ) -> Result<Vec<Envelope>, EmailClientStdError>

Lists envelopes from mailbox. with_attachment is honoured by IMAP / Maildir / M2dir; JMAP returns the attachment flag inline and ignores the parameter.

Source

pub fn search_envelopes( &mut self, mailbox: &str, query: Option<&SearchEmailsQuery>, page: Option<u32>, page_size: Option<u32>, with_attachment: bool, ) -> Result<Vec<Envelope>, EmailClientStdError>

Available on crate feature search only.

Searches envelopes against the shared query.

Source

pub fn store_flags( &mut self, mailbox: &str, ids: &[&str], flags: &[Flag], op: FlagOp, ) -> Result<(), EmailClientStdError>

Adds, sets or removes flags on ids.

Source

pub fn get_message( &mut self, mailbox: &str, id: &str, ) -> Result<Vec<u8>, EmailClientStdError>

Fetches one message’s raw RFC 5322 bytes.

Source

pub fn add_message( &mut self, mailbox: &str, flags: &[Flag], raw: Vec<u8>, ) -> Result<String, EmailClientStdError>

Adds raw to mailbox with the given flags. Returns the newly-assigned id.

Source

pub fn create_mailbox(&mut self, name: &str) -> Result<(), EmailClientStdError>

Creates name as a new mailbox.

Source

pub fn delete_mailbox(&mut self, name: &str) -> Result<(), EmailClientStdError>

Deletes mailbox name.

Source

pub fn delete_message( &mut self, mailbox: &str, id: &str, ) -> Result<(), EmailClientStdError>

Deletes one message permanently.

Source

pub fn copy_messages( &mut self, from: &str, to: &str, ids: &[&str], ) -> Result<(), EmailClientStdError>

Copies ids from from to to.

Source

pub fn move_messages( &mut self, from: &str, to: &str, ids: &[&str], ) -> Result<(), EmailClientStdError>

Moves ids from from to to.

Source

pub fn diff_envelopes( &mut self, mailbox: &str, state: Option<&[u8]>, ) -> Result<EnvelopeDiff, EmailClientStdError>

Surfaces a pre-diffed envelope delta against the opaque per-backend state checkpoint, when the registered backend supports it.

state is the blob returned by a previous successful call (or None on first sync); the caller stores the returned checkpoint for next time. Returns EnvelopeDiff::FullListRequired when the backend cannot produce an incremental view (capability missing, state invalidated, server bumped UIDVALIDITY).

Currently routed to IMAP (QRESYNC / CONDSTORE) and JMAP (Email/changes); Maildir, m2dir and SMTP fall through to EmailClientStdError::UnsupportedOperation.

Source

pub fn diff_mailboxes( &mut self, state: Option<&[u8]>, ) -> Result<MailboxDiff, EmailClientStdError>

Probes whether the mailbox set has changed since state. JMAP uses Mailbox/changes for a constant-cost “anything changed?” answer; backends without an account-global mailbox state token (IMAP, Maildir, m2dir) fall through to EmailClientStdError::UnsupportedOperation so the caller can drop to a normal Self::list_mailboxes.

Source

pub fn watch_mailbox( &mut self, mailbox: &str, shutdown: Arc<AtomicBool>, tx: Sender<WatchEvent>, ) -> Result<(), EmailClientStdError>

Available on crate features imap or jmap only.

Watches mailbox for envelope-level deltas, forwarding events through tx. Priority: JMAP → IMAP (no filesystem watch yet).

Source

pub fn send_message(&mut self, raw: Vec<u8>) -> Result<(), EmailClientStdError>

Available on crate features jmap or smtp only.

Sends a raw RFC 5322 message. JMAP routes via EmailSubmission/set when registered; otherwise SMTP runs the RFC 5321 mail transaction.

Trait Implementations§

Source§

impl Default for EmailClientStd

Source§

fn default() -> EmailClientStd

Returns the “default value” for a type. Read more

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<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

Source§

type Proj<U: 'src> = U

Source§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

Source§

impl<T, S> SpanWrap<S> for T
where S: WrappingSpan<T>,

Source§

fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned

Invokes WrappingSpan::make_wrapped to wrap an AST node in a span.
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.