Skip to main content

JmapClientStd

Struct JmapClientStd 

Source
pub struct JmapClientStd {
    pub stream: Box<dyn JmapStream>,
    pub http_auth: SecretString,
    pub session: Option<JmapSession>,
}
Available on crate feature client only.
Expand description

Std-blocking JMAP client wrapping a single boxed stream.

Fields§

§stream: Box<dyn JmapStream>§http_auth: SecretString§session: Option<JmapSession>

Implementations§

Source§

impl JmapClientStd

Source

pub fn new<S: Read + Write + Send + 'static>( stream: S, http_auth: SecretString, ) -> Self

Builds a client around stream. The caller is responsible for opening the connection (TCP, TLS handshake if needed) and for the bearer token / authorization header value.

Source

pub fn run<C, T, E>(&mut self, coroutine: C) -> Result<T, JmapClientStdError>
where C: JmapCoroutine<Yield = JmapYield, Return = Result<T, E>>, JmapClientStdError: From<E>,

Drives any standard-shape coroutine (Yield = JmapYield) against the wrapped stream until it terminates.

Redirect-aware coroutines (JmapSessionGet, JmapBlobUpload, JmapBlobDownload) and the streaming JmapEventSource have their own per-method loops.

Source

pub fn from_parts<S: Read + Write + Send + 'static>( stream: S, http_auth: SecretString, session: JmapSession, ) -> Self

Builds a client from a pre-connected stream and an already-discovered JmapSession. Skips Self::session_get.

Source

pub fn connect( url: &Url, tls: &Tls, http_auth: SecretString, ) -> Result<Self, JmapClientStdError>

Available on crate features native-tls or rustls-aws or rustls-ring only.

Connects to url, doing a TLS handshake for https / jmaps (plain TCP for http / jmap). ALPN comes from tls.rustls.alpn (see default_alpn); empty vec skips ALPN.

Source

pub fn set_stream<S: Read + Write + Send + 'static>(&mut self, stream: S)

Replaces the underlying stream; useful when apiUrl, uploadUrl or downloadUrl resolves to a different authority than the first connection target, or after a redirect.

Source

pub fn session(&self) -> Option<&JmapSession>

Returns the cached session, if Self::session_get has run.

Source

pub fn http_auth(&self) -> &SecretString

Returns the pre-formatted HTTP Authorization header value.

Source

pub fn session_get( &mut self, url: &Url, ) -> Result<&JmapSession, JmapClientStdError>

Runs JmapSessionGet and caches the discovered session.

url is either a base URL for /.well-known/jmap discovery or a direct session endpoint. A 3xx response terminates with JmapClientStdError::UnexpectedRedirect.

Source

pub fn send_raw( &mut self, request: JmapRequest, ) -> Result<JmapResponse, JmapClientStdError>

Sends a raw JMAP request and returns the raw JmapResponse. Useful for passthrough CLIs and ad-hoc requests with custom using capabilities.

Source

pub fn blob_upload( &mut self, upload_url: &Url, content_type: &str, data: Vec<u8>, ) -> Result<JmapBlobUploadOutput, JmapClientStdError>

Uploads a blob to upload_url (RFC 8620 §6.1). The caller must resolve the session’s uploadUrl template (e.g. substitute {accountId}). A 3xx response terminates with JmapClientStdError::UnexpectedRedirect.

Source

pub fn blob_download( &mut self, download_url: &Url, ) -> Result<Vec<u8>, JmapClientStdError>

Downloads a blob from download_url (RFC 8620 §6.2). The caller must resolve the session’s downloadUrl template. A 3xx response terminates with JmapClientStdError::UnexpectedRedirect.

Source

pub fn mailbox_get( &mut self, opts: JmapMailboxGetOptions, ) -> Result<JmapMailboxGetOutput, JmapClientStdError>

Runs JmapMailboxGet (Mailbox/get).

Source

pub fn mailbox_query( &mut self, opts: JmapMailboxQueryOptions, ) -> Result<JmapMailboxQueryOutput, JmapClientStdError>

Runs JmapMailboxQuery (batched Mailbox/query + Mailbox/get).

Source

pub fn mailbox_set( &mut self, args: JmapMailboxSetArgs, ) -> Result<JmapMailboxSetOutput, JmapClientStdError>

Runs JmapMailboxSet (Mailbox/set).

Source

pub fn mailbox_changes( &mut self, since_state: impl Into<String>, opts: JmapMailboxChangesOptions, ) -> Result<JmapChangesOutput, JmapClientStdError>

Runs JmapMailboxChanges (Mailbox/changes).

Source

pub fn email_get( &mut self, ids: Vec<String>, opts: JmapEmailGetOptions, ) -> Result<JmapEmailGetOutput, JmapClientStdError>

Runs JmapEmailGet (Email/get).

Source

pub fn email_query( &mut self, opts: JmapEmailQueryOptions, ) -> Result<JmapEmailQueryOutput, JmapClientStdError>

Runs JmapEmailQuery (batched Email/query + Email/get).

Source

pub fn email_set( &mut self, args: JmapEmailSetArgs, ) -> Result<JmapEmailSetOutput, JmapClientStdError>

Runs JmapEmailSet (Email/set).

Source

pub fn email_changes( &mut self, since_state: impl Into<String>, opts: JmapEmailChangesOptions, ) -> Result<JmapChangesOutput, JmapClientStdError>

Runs JmapEmailChanges (Email/changes).

Source

pub fn email_copy( &mut self, from_account_id: impl Into<String>, emails: BTreeMap<String, JmapEmailCopyArgs>, ) -> Result<JmapEmailCopyOutput, JmapClientStdError>

Runs JmapEmailCopy (Email/copy).

Source

pub fn email_import( &mut self, emails: BTreeMap<String, JmapEmailImportArgs>, ) -> Result<JmapEmailImportOutput, JmapClientStdError>

Runs JmapEmailImport (Email/import).

Source

pub fn email_parse( &mut self, blob_ids: Vec<String>, opts: JmapEmailParseOptions, ) -> Result<JmapEmailParseOutput, JmapClientStdError>

Runs JmapEmailParse (Email/parse).

Source

pub fn thread_get( &mut self, ids: Vec<String>, ) -> Result<JmapThreadGetOutput, JmapClientStdError>

Runs JmapThreadGet (Thread/get).

Source

pub fn thread_changes( &mut self, since_state: impl Into<String>, opts: JmapThreadChangesOptions, ) -> Result<JmapChangesOutput, JmapClientStdError>

Runs JmapThreadChanges (Thread/changes).

Source

pub fn identity_get( &mut self, opts: JmapIdentityGetOptions, ) -> Result<JmapIdentityGetOutput, JmapClientStdError>

Runs JmapIdentityGet (Identity/get).

Source

pub fn identity_set( &mut self, args: JmapIdentitySetArgs, ) -> Result<JmapIdentitySetOutput, JmapClientStdError>

Runs JmapIdentitySet (Identity/set).

Source

pub fn email_submission_get( &mut self, opts: JmapEmailSubmissionGetOptions, ) -> Result<JmapEmailSubmissionGetOutput, JmapClientStdError>

Runs JmapEmailSubmissionGet (EmailSubmission/get).

Source

pub fn email_submission_query( &mut self, opts: JmapEmailSubmissionQueryOptions, ) -> Result<JmapEmailSubmissionQueryOutput, JmapClientStdError>

Runs JmapEmailSubmissionQuery (batched EmailSubmission/query + EmailSubmission/get).

Source

pub fn email_submission_set( &mut self, submissions: BTreeMap<String, JmapEmailSubmissionCreate>, ) -> Result<JmapEmailSubmissionSetOutput, JmapClientStdError>

Runs JmapEmailSubmissionSet (EmailSubmission/set).

Source

pub fn email_submission_cancel( &mut self, ids: Vec<String>, ) -> Result<JmapEmailSubmissionCancelOutput, JmapClientStdError>

Runs JmapEmailSubmissionCancel (EmailSubmission/set with undoStatus: "canceled").

Source

pub fn vacation_response_get( &mut self, ) -> Result<Option<JmapVacationResponse>, JmapClientStdError>

Runs JmapVacationResponseGet; returns the singleton, if any.

Source

pub fn vacation_response_set( &mut self, patch: JmapVacationResponseUpdate, ) -> Result<Option<JmapVacationResponse>, JmapClientStdError>

Runs JmapVacationResponseSet; returns the updated singleton if the server echoed it back.

Trait Implementations§

Source§

impl Debug for JmapClientStd

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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<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.