pub struct EmailClientStd {
pub imap: Option<ImapClientStd>,
pub jmap: Option<JmapClientStd>,
pub smtp: Option<SmtpClientStd>,
pub maildir: Option<MaildirClient>,
pub m2dir: Option<M2dirClient>,
}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>imap only.jmap: Option<JmapClientStd>jmap only.smtp: Option<SmtpClientStd>smtp only.maildir: Option<MaildirClient>maildir only.m2dir: Option<M2dirClient>m2dir only.Implementations§
Source§impl EmailClientStd
impl EmailClientStd
Sourcepub fn with_imap(self, client: ImapClientStd) -> Self
Available on crate feature imap only.
pub fn with_imap(self, client: ImapClientStd) -> Self
imap only.Registers the IMAP backend.
Sourcepub fn with_jmap(self, client: JmapClientStd) -> Self
Available on crate feature jmap only.
pub fn with_jmap(self, client: JmapClientStd) -> Self
jmap only.Registers the JMAP backend.
Sourcepub fn with_smtp(self, client: SmtpClientStd) -> Self
Available on crate feature smtp only.
pub fn with_smtp(self, client: SmtpClientStd) -> Self
smtp only.Registers the SMTP backend.
Sourcepub fn with_maildir(self, client: MaildirClient) -> Self
Available on crate feature maildir only.
pub fn with_maildir(self, client: MaildirClient) -> Self
maildir only.Registers the Maildir backend.
Sourcepub fn with_m2dir(self, client: M2dirClient) -> Self
Available on crate feature m2dir only.
pub fn with_m2dir(self, client: M2dirClient) -> Self
m2dir only.Registers the m2dir backend.
Sourcepub 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.
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>
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.
Sourcepub 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.
pub fn connect_jmap( self, url: &Url, tls: &Tls, http_auth: SecretString, ) -> Result<Self, EmailClientStdError>
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).
Sourcepub 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.
pub fn connect_smtp( self, url: &Url, tls: &Tls, starttls: bool, domain: EhloDomain<'_>, sasl: Option<impl Into<Sasl>>, ) -> Result<Self, EmailClientStdError>
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.
Sourcepub fn ping(&mut self) -> Result<(), EmailClientStdError>
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.
Sourcepub fn list_mailboxes(
&mut self,
with_counts: bool,
) -> Result<Vec<Mailbox>, EmailClientStdError>
pub fn list_mailboxes( &mut self, with_counts: bool, ) -> Result<Vec<Mailbox>, EmailClientStdError>
Lists every visible mailbox via the highest-priority registered storage backend.
Sourcepub fn list_envelopes(
&mut self,
mailbox: &str,
page: Option<u32>,
page_size: Option<u32>,
with_attachment: bool,
) -> Result<Vec<Envelope>, EmailClientStdError>
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.
Sourcepub 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.
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>
search only.Searches envelopes against the shared query.
Sourcepub fn store_flags(
&mut self,
mailbox: &str,
ids: &[&str],
flags: &[Flag],
op: FlagOp,
) -> Result<(), EmailClientStdError>
pub fn store_flags( &mut self, mailbox: &str, ids: &[&str], flags: &[Flag], op: FlagOp, ) -> Result<(), EmailClientStdError>
Adds, sets or removes flags on ids.
Sourcepub fn get_message(
&mut self,
mailbox: &str,
id: &str,
) -> Result<Vec<u8>, EmailClientStdError>
pub fn get_message( &mut self, mailbox: &str, id: &str, ) -> Result<Vec<u8>, EmailClientStdError>
Fetches one message’s raw RFC 5322 bytes.
Sourcepub fn add_message(
&mut self,
mailbox: &str,
flags: &[Flag],
raw: Vec<u8>,
) -> Result<String, EmailClientStdError>
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.
Sourcepub fn create_mailbox(&mut self, name: &str) -> Result<(), EmailClientStdError>
pub fn create_mailbox(&mut self, name: &str) -> Result<(), EmailClientStdError>
Creates name as a new mailbox.
Sourcepub fn delete_mailbox(&mut self, name: &str) -> Result<(), EmailClientStdError>
pub fn delete_mailbox(&mut self, name: &str) -> Result<(), EmailClientStdError>
Deletes mailbox name.
Sourcepub fn delete_message(
&mut self,
mailbox: &str,
id: &str,
) -> Result<(), EmailClientStdError>
pub fn delete_message( &mut self, mailbox: &str, id: &str, ) -> Result<(), EmailClientStdError>
Deletes one message permanently.
Sourcepub fn copy_messages(
&mut self,
from: &str,
to: &str,
ids: &[&str],
) -> Result<(), EmailClientStdError>
pub fn copy_messages( &mut self, from: &str, to: &str, ids: &[&str], ) -> Result<(), EmailClientStdError>
Copies ids from from to to.
Sourcepub fn move_messages(
&mut self,
from: &str,
to: &str,
ids: &[&str],
) -> Result<(), EmailClientStdError>
pub fn move_messages( &mut self, from: &str, to: &str, ids: &[&str], ) -> Result<(), EmailClientStdError>
Moves ids from from to to.
Sourcepub fn diff_envelopes(
&mut self,
mailbox: &str,
state: Option<&[u8]>,
) -> Result<EnvelopeDiff, EmailClientStdError>
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.
Sourcepub fn diff_mailboxes(
&mut self,
state: Option<&[u8]>,
) -> Result<MailboxDiff, EmailClientStdError>
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.
Sourcepub fn watch_mailbox(
&mut self,
mailbox: &str,
shutdown: Arc<AtomicBool>,
tx: Sender<WatchEvent>,
) -> Result<(), EmailClientStdError>
Available on crate features imap or jmap only.
pub fn watch_mailbox( &mut self, mailbox: &str, shutdown: Arc<AtomicBool>, tx: Sender<WatchEvent>, ) -> Result<(), EmailClientStdError>
imap or jmap only.Watches mailbox for envelope-level deltas, forwarding events
through tx. Priority: JMAP → IMAP (no filesystem watch yet).
Sourcepub fn send_message(&mut self, raw: Vec<u8>) -> Result<(), EmailClientStdError>
Available on crate features jmap or smtp only.
pub fn send_message(&mut self, raw: Vec<u8>) -> Result<(), EmailClientStdError>
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
impl Default for EmailClientStd
Source§fn default() -> EmailClientStd
fn default() -> EmailClientStd
Auto Trait Implementations§
impl !RefUnwindSafe for EmailClientStd
impl !Sync for EmailClientStd
impl !UnwindSafe for EmailClientStd
impl Freeze for EmailClientStd
impl Send for EmailClientStd
impl Unpin for EmailClientStd
impl UnsafeUnpin for EmailClientStd
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
Source§fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
WrappingSpan::make_wrapped to wrap an AST node in a span.