Skip to main content

GmailClientStd

Struct GmailClientStd 

Source
pub struct GmailClientStd {
    pub stream: Box<dyn GmailStream>,
    pub auth: HttpAuthBearer,
    pub user_id: String,
}
Available on crate feature client only.
Expand description

Standard, blocking Gmail client.

Owns the stream, the bearer credential and the mailbox owner; each convenience method builds the matching coroutine and runs it to completion. Coroutines without a convenience method go through GmailClientStd::run.

Fields§

§stream: Box<dyn GmailStream>

The underlying TCP or TLS stream.

§auth: HttpAuthBearer

The OAuth 2.0 bearer credential added to every request.

§user_id: String

Owner of the mailbox the requests target (usually me).

Implementations§

Source§

impl GmailClientStd

Source

pub fn new<S: Read + Write + Send + 'static>( stream: S, token: impl ToString, options: GmailClientStdConnectOptions, ) -> Self

Builds a client over an already-connected stream.

Source

pub fn connect( token: impl ToString, options: GmailClientStdConnectOptions, ) -> Result<Self, GmailClientStdError>

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

Opens a TCP/TLS connection to gmail.googleapis.com and builds the client around it.

Source

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

Replaces the underlying stream, e.g. after reconnecting.

Source

pub fn run<C, T>( &mut self, coroutine: C, ) -> Result<GmailSendOutput<T>, GmailClientStdError>

Runs the given coroutine to completion against the stream, reading on WantsRead and writing on WantsWrite.

Source

pub fn profile_get( &mut self, ) -> Result<GmailSendOutput<GmailProfile>, GmailClientStdError>

Gets the profile of the mailbox (users.getProfile).

Source

pub fn watch( &mut self, request: &GmailWatchRequest, ) -> Result<GmailSendOutput<GmailWatchResponse>, GmailClientStdError>

Sets up Pub/Sub push notifications (users.watch).

Source

pub fn stop( &mut self, ) -> Result<GmailSendOutput<GmailNoResponse>, GmailClientStdError>

Stops Pub/Sub push notifications (users.stop).

Source

pub fn labels_list( &mut self, ) -> Result<GmailSendOutput<GmailLabelsListResponse>, GmailClientStdError>

Lists the labels of the mailbox (users.labels.list).

Source

pub fn label_get( &mut self, id: &str, ) -> Result<GmailSendOutput<GmailLabel>, GmailClientStdError>

Gets a label by id (users.labels.get).

Source

pub fn label_create( &mut self, label: &GmailLabel, ) -> Result<GmailSendOutput<GmailLabel>, GmailClientStdError>

Creates the given label (users.labels.create).

Source

pub fn label_update( &mut self, label: &GmailLabel, ) -> Result<GmailSendOutput<GmailLabel>, GmailClientStdError>

Updates the given label in place (users.labels.update).

Source

pub fn label_patch( &mut self, label: &GmailLabel, ) -> Result<GmailSendOutput<GmailLabel>, GmailClientStdError>

Patches the given label (users.labels.patch).

Source

pub fn label_delete( &mut self, id: &str, ) -> Result<GmailSendOutput<GmailNoResponse>, GmailClientStdError>

Deletes a label by id (users.labels.delete).

Source

pub fn messages_list( &mut self, params: &GmailMessagesListParams<'_>, ) -> Result<GmailSendOutput<GmailMessagesListResponse>, GmailClientStdError>

Lists message ids matching the params (users.messages.list).

Source

pub fn message_get( &mut self, id: &str, format: GmailMessageFormat, metadata_headers: &[&str], ) -> Result<GmailSendOutput<GmailMessage>, GmailClientStdError>

Gets a message by id (users.messages.get).

Source

pub fn message_send( &mut self, message: &GmailMessage, ) -> Result<GmailSendOutput<GmailMessageId>, GmailClientStdError>

Sends the given message (users.messages.send).

Source

pub fn message_modify( &mut self, id: &str, add_label_ids: &[String], remove_label_ids: &[String], ) -> Result<GmailSendOutput<GmailMessage>, GmailClientStdError>

Adds and removes labels on a message (users.messages.modify).

Source

pub fn message_trash( &mut self, id: &str, ) -> Result<GmailSendOutput<GmailMessage>, GmailClientStdError>

Moves a message to the trash (users.messages.trash).

Source

pub fn message_untrash( &mut self, id: &str, ) -> Result<GmailSendOutput<GmailMessage>, GmailClientStdError>

Restores a message from the trash (users.messages.untrash).

Source

pub fn message_delete( &mut self, id: &str, ) -> Result<GmailSendOutput<GmailNoResponse>, GmailClientStdError>

Permanently deletes a message (users.messages.delete).

Trait Implementations§

Source§

impl Debug for GmailClientStd

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.