pub struct JmapClientStd {
pub inner: JmapClientStd,
pub identity_id: Option<String>,
pub drafts_mailbox_id: Option<String>,
}client and jmap only.Expand description
Light JMAP client built on top of the io-jmap type-erased inner.
Unlike IMAP, JMAP carries no auto_select (destroys are global)
and no separate capability list (capabilities are exposed via the
inner client’s cached JmapSession).
Two extra options are required for Self::send_message: the
JMAP identity to submit under (Identity/get type=role:identity)
and the drafts mailbox id (Mailbox/query role: drafts).
Populate them after Self::session_get when sending is in scope.
Fields§
§inner: JmapClientStd§identity_id: Option<String>§drafts_mailbox_id: Option<String>Implementations§
Source§impl JmapClientStd
impl JmapClientStd
Sourcepub fn new<S: Read + Write + Send + 'static>(
stream: S,
http_auth: SecretString,
) -> Self
pub fn new<S: Read + Write + Send + 'static>( stream: S, http_auth: SecretString, ) -> Self
Wraps an already-connected stream with the bearer / basic HTTP
credential. The session must be discovered via
Self::session_get before any shared-API method is called.
Sourcepub fn run<C, T, E>(&mut self, coroutine: C) -> Result<T, JmapClientError>
pub fn run<C, T, E>(&mut self, coroutine: C) -> Result<T, JmapClientError>
Pumps any standard-shape JMAP coroutine
(Yield = JmapYield, Return = Result<T, E>) against the
inner client’s stream until it terminates.
Reaches into Self::inner for raw field access rather than
delegating to InnerJmapClientStd::run so error variants
route through JmapClientError directly.
Sourcepub fn session_get(&mut self, url: &Url) -> Result<(), JmapClientError>
pub fn session_get(&mut self, url: &Url) -> Result<(), JmapClientError>
Discovers the JMAP session against url and caches it on the
inner client. Pass either a base URL for /.well-known/jmap
discovery or a direct session endpoint URL.
Sourcepub fn list_mailboxes(
&mut self,
with_counts: bool,
) -> Result<Vec<Mailbox>, JmapClientError>
pub fn list_mailboxes( &mut self, with_counts: bool, ) -> Result<Vec<Mailbox>, JmapClientError>
Lists every JMAP mailbox visible to the session’s primary
mail account. When with_counts is set, includes
totalEmails / unreadEmails (still one round-trip; JMAP
returns counts inline).
Sourcepub fn list_envelopes(
&mut self,
mailbox: &str,
page: Option<u32>,
page_size: Option<u32>,
) -> Result<Vec<Envelope>, JmapClientError>
pub fn list_envelopes( &mut self, mailbox: &str, page: Option<u32>, page_size: Option<u32>, ) -> Result<Vec<Envelope>, JmapClientError>
Lists envelopes from mailbox. page = None and
page_size = None fetch the whole mailbox.
Sourcepub fn search_envelopes(
&mut self,
mailbox: &str,
query: Option<&SearchEmailsQuery>,
page: Option<u32>,
page_size: Option<u32>,
) -> Result<Vec<Envelope>, JmapClientError>
Available on crate feature search only.
pub fn search_envelopes( &mut self, mailbox: &str, query: Option<&SearchEmailsQuery>, page: Option<u32>, page_size: Option<u32>, ) -> Result<Vec<Envelope>, JmapClientError>
search only.Searches envelopes in mailbox against the shared query.
Pagination is applied to the SORT-ordered id list; date
predicates are re-checked client-side because JMAP filters on
receivedAt while the shared DSL targets sentAt.
Sourcepub fn store_flags(
&mut self,
mailbox: &str,
ids: &[&str],
flags: &[Flag],
op: FlagOp,
) -> Result<(), JmapClientError>
pub fn store_flags( &mut self, mailbox: &str, ids: &[&str], flags: &[Flag], op: FlagOp, ) -> Result<(), JmapClientError>
Adds, sets, or removes flags (JMAP keywords) on a JMAP email
id set. mailbox is unused: JMAP keywords are global per
email, not per mailbox.
Sourcepub fn get_message(
&mut self,
mailbox: &str,
id: &str,
) -> Result<Vec<u8>, JmapClientError>
pub fn get_message( &mut self, mailbox: &str, id: &str, ) -> Result<Vec<u8>, JmapClientError>
Fetches one message’s raw RFC 5322 bytes via Email/get
(resolving the blob id) then Blob/download.
Sourcepub fn add_message(
&mut self,
mailbox: &str,
flags: &[Flag],
raw: Vec<u8>,
) -> Result<String, JmapClientError>
pub fn add_message( &mut self, mailbox: &str, flags: &[Flag], raw: Vec<u8>, ) -> Result<String, JmapClientError>
Uploads raw as a blob then imports it into mailbox with
the requested keywords. Returns the created email id.
Sourcepub fn create_mailbox(&mut self, name: &str) -> Result<(), JmapClientError>
pub fn create_mailbox(&mut self, name: &str) -> Result<(), JmapClientError>
Creates name as a top-level JMAP mailbox.
Sourcepub fn delete_mailbox(&mut self, name: &str) -> Result<(), JmapClientError>
pub fn delete_mailbox(&mut self, name: &str) -> Result<(), JmapClientError>
Deletes the JMAP mailbox named name; drops every email that
lives only in that mailbox (onDestroyRemoveEmails: true).
Sourcepub fn delete_message(
&mut self,
mailbox: &str,
id: &str,
) -> Result<(), JmapClientError>
pub fn delete_message( &mut self, mailbox: &str, id: &str, ) -> Result<(), JmapClientError>
Destroys the JMAP email by id (global delete; removes the email from every mailbox it references).
Sourcepub fn copy_messages(
&mut self,
from: &str,
to: &str,
ids: &[&str],
) -> Result<(), JmapClientError>
pub fn copy_messages( &mut self, from: &str, to: &str, ids: &[&str], ) -> Result<(), JmapClientError>
Copies a JMAP email id set into to by adding to’s
mailbox-id reference to each email. The from argument is
part of the shared signature for symmetry with IMAP / Maildir
but unused: existing mailboxIds carry the source reference.
Sourcepub fn move_messages(
&mut self,
from: &str,
to: &str,
ids: &[&str],
) -> Result<(), JmapClientError>
pub fn move_messages( &mut self, from: &str, to: &str, ids: &[&str], ) -> Result<(), JmapClientError>
Moves a JMAP email id set from from to to; adds to’s
id and removes from’s id in the same Email/set patch.
Sourcepub fn send_message(&mut self, raw: Vec<u8>) -> Result<(), JmapClientError>
pub fn send_message(&mut self, raw: Vec<u8>) -> Result<(), JmapClientError>
Queues raw for delivery via EmailSubmission/set.
Requires Self::identity_id and Self::drafts_mailbox_id
to be populated.
Sourcepub fn watch_mailbox(
&mut self,
mailbox: &str,
shutdown: Arc<AtomicBool>,
tx: Sender<WatchEvent>,
) -> Result<(), JmapClientError>
pub fn watch_mailbox( &mut self, mailbox: &str, shutdown: Arc<AtomicBool>, tx: Sender<WatchEvent>, ) -> Result<(), JmapClientError>
Watches mailbox for envelope-level deltas via the JMAP
EventSource (closeafter=state) + Email/changes +
Email/get loop, forwarding every event through tx.
Blocks the current thread. Returns Ok(()) when
shutdown flips, when the receiver behind tx is dropped,
or when the protocol layer errors out.
Sourcepub fn diff_envelopes(
&mut self,
_mailbox: &str,
state: Option<&[u8]>,
) -> Result<EnvelopeDiff, JmapClientError>
pub fn diff_envelopes( &mut self, _mailbox: &str, state: Option<&[u8]>, ) -> Result<EnvelopeDiff, JmapClientError>
Returns the Email/changes-driven envelope delta against the
opaque per-backend state checkpoint.
Decodes state as the cached Email/state token, then walks
Email/changes rounds until hasMoreChanges clears. Created
ids are turned into new envelopes via Email/get; updated ids
surface as FlagUpdate entries. The mailbox argument is
part of the shared signature: JMAP Email/changes is global
per account and ignores it. Falls back to
EnvelopeDiff::FullListRequired when the cached state is
unusable or the server returns cannotCalculateChanges.
Sourcepub fn diff_mailboxes(
&mut self,
state: Option<&[u8]>,
) -> Result<MailboxDiff, JmapClientError>
pub fn diff_mailboxes( &mut self, state: Option<&[u8]>, ) -> Result<MailboxDiff, JmapClientError>
Returns the Mailbox/changes-driven mailbox-set delta against
the opaque per-backend state checkpoint. A single round trip:
any non-empty bucket (or the server bumping the state) maps to
MailboxDiff::Changed; an idle bucket maps to
MailboxDiff::Unchanged. On cannotCalculateChanges the
caller is told to re-list via Changed { new_state: None }.
Source§impl JmapClientStd
impl JmapClientStd
Sourcepub fn connect(
url: &Url,
tls: &Tls,
http_auth: SecretString,
) -> Result<Self, JmapClientError>
Available on crate features native-tls or rustls-aws or rustls-ring only.
pub fn connect( url: &Url, tls: &Tls, http_auth: SecretString, ) -> Result<Self, JmapClientError>
native-tls or rustls-aws or rustls-ring only.Opens a TCP / TLS connection to url, builds the inner
client around it, then runs session_get to discover the
JMAP session.
url is either a base URL for /.well-known/jmap discovery
or a direct session endpoint.
Auto Trait Implementations§
impl !RefUnwindSafe for JmapClientStd
impl !Sync for JmapClientStd
impl !UnwindSafe for JmapClientStd
impl Freeze for JmapClientStd
impl Send for JmapClientStd
impl Unpin for JmapClientStd
impl UnsafeUnpin for JmapClientStd
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.