pub struct GmailClientStd {
pub stream: Box<dyn GmailStream>,
pub auth: HttpAuthBearer,
pub user_id: String,
}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: HttpAuthBearerThe OAuth 2.0 bearer credential added to every request.
user_id: StringOwner of the mailbox the requests target (usually me).
Implementations§
Source§impl GmailClientStd
impl GmailClientStd
Sourcepub fn new<S: Read + Write + Send + 'static>(
stream: S,
token: impl ToString,
options: GmailClientStdConnectOptions,
) -> Self
pub fn new<S: Read + Write + Send + 'static>( stream: S, token: impl ToString, options: GmailClientStdConnectOptions, ) -> Self
Builds a client over an already-connected stream.
Sourcepub fn connect(
token: impl ToString,
options: GmailClientStdConnectOptions,
) -> Result<Self, GmailClientStdError>
Available on crate features native-tls or rustls-aws or rustls-ring only.
pub fn connect( token: impl ToString, options: GmailClientStdConnectOptions, ) -> Result<Self, GmailClientStdError>
native-tls or rustls-aws or rustls-ring only.Opens a TCP/TLS connection to gmail.googleapis.com and builds
the client around it.
Sourcepub fn set_stream<S: Read + Write + Send + 'static>(&mut self, stream: S)
pub fn set_stream<S: Read + Write + Send + 'static>(&mut self, stream: S)
Replaces the underlying stream, e.g. after reconnecting.
Sourcepub fn run<C, T>(
&mut self,
coroutine: C,
) -> Result<GmailSendOutput<T>, GmailClientStdError>
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.
Sourcepub fn profile_get(
&mut self,
) -> Result<GmailSendOutput<GmailProfile>, GmailClientStdError>
pub fn profile_get( &mut self, ) -> Result<GmailSendOutput<GmailProfile>, GmailClientStdError>
Gets the profile of the mailbox (users.getProfile).
Sourcepub fn watch(
&mut self,
request: &GmailWatchRequest,
) -> Result<GmailSendOutput<GmailWatchResponse>, GmailClientStdError>
pub fn watch( &mut self, request: &GmailWatchRequest, ) -> Result<GmailSendOutput<GmailWatchResponse>, GmailClientStdError>
Sets up Pub/Sub push notifications (users.watch).
Sourcepub fn stop(
&mut self,
) -> Result<GmailSendOutput<GmailNoResponse>, GmailClientStdError>
pub fn stop( &mut self, ) -> Result<GmailSendOutput<GmailNoResponse>, GmailClientStdError>
Stops Pub/Sub push notifications (users.stop).
Sourcepub fn labels_list(
&mut self,
) -> Result<GmailSendOutput<GmailLabelsListResponse>, GmailClientStdError>
pub fn labels_list( &mut self, ) -> Result<GmailSendOutput<GmailLabelsListResponse>, GmailClientStdError>
Lists the labels of the mailbox (users.labels.list).
Sourcepub fn label_get(
&mut self,
id: &str,
) -> Result<GmailSendOutput<GmailLabel>, GmailClientStdError>
pub fn label_get( &mut self, id: &str, ) -> Result<GmailSendOutput<GmailLabel>, GmailClientStdError>
Gets a label by id (users.labels.get).
Sourcepub fn label_create(
&mut self,
label: &GmailLabel,
) -> Result<GmailSendOutput<GmailLabel>, GmailClientStdError>
pub fn label_create( &mut self, label: &GmailLabel, ) -> Result<GmailSendOutput<GmailLabel>, GmailClientStdError>
Creates the given label (users.labels.create).
Sourcepub fn label_update(
&mut self,
label: &GmailLabel,
) -> Result<GmailSendOutput<GmailLabel>, GmailClientStdError>
pub fn label_update( &mut self, label: &GmailLabel, ) -> Result<GmailSendOutput<GmailLabel>, GmailClientStdError>
Updates the given label in place (users.labels.update).
Sourcepub fn label_patch(
&mut self,
label: &GmailLabel,
) -> Result<GmailSendOutput<GmailLabel>, GmailClientStdError>
pub fn label_patch( &mut self, label: &GmailLabel, ) -> Result<GmailSendOutput<GmailLabel>, GmailClientStdError>
Patches the given label (users.labels.patch).
Sourcepub fn label_delete(
&mut self,
id: &str,
) -> Result<GmailSendOutput<GmailNoResponse>, GmailClientStdError>
pub fn label_delete( &mut self, id: &str, ) -> Result<GmailSendOutput<GmailNoResponse>, GmailClientStdError>
Deletes a label by id (users.labels.delete).
Sourcepub fn messages_list(
&mut self,
params: &GmailMessagesListParams<'_>,
) -> Result<GmailSendOutput<GmailMessagesListResponse>, GmailClientStdError>
pub fn messages_list( &mut self, params: &GmailMessagesListParams<'_>, ) -> Result<GmailSendOutput<GmailMessagesListResponse>, GmailClientStdError>
Lists message ids matching the params (users.messages.list).
Sourcepub fn message_get(
&mut self,
id: &str,
format: GmailMessageFormat,
metadata_headers: &[&str],
) -> Result<GmailSendOutput<GmailMessage>, GmailClientStdError>
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).
Sourcepub fn message_send(
&mut self,
message: &GmailMessage,
) -> Result<GmailSendOutput<GmailMessageId>, GmailClientStdError>
pub fn message_send( &mut self, message: &GmailMessage, ) -> Result<GmailSendOutput<GmailMessageId>, GmailClientStdError>
Sends the given message (users.messages.send).
Sourcepub fn message_modify(
&mut self,
id: &str,
add_label_ids: &[String],
remove_label_ids: &[String],
) -> Result<GmailSendOutput<GmailMessage>, GmailClientStdError>
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).
Sourcepub fn message_trash(
&mut self,
id: &str,
) -> Result<GmailSendOutput<GmailMessage>, GmailClientStdError>
pub fn message_trash( &mut self, id: &str, ) -> Result<GmailSendOutput<GmailMessage>, GmailClientStdError>
Moves a message to the trash (users.messages.trash).
Sourcepub fn message_untrash(
&mut self,
id: &str,
) -> Result<GmailSendOutput<GmailMessage>, GmailClientStdError>
pub fn message_untrash( &mut self, id: &str, ) -> Result<GmailSendOutput<GmailMessage>, GmailClientStdError>
Restores a message from the trash (users.messages.untrash).
Sourcepub fn message_delete(
&mut self,
id: &str,
) -> Result<GmailSendOutput<GmailNoResponse>, GmailClientStdError>
pub fn message_delete( &mut self, id: &str, ) -> Result<GmailSendOutput<GmailNoResponse>, GmailClientStdError>
Permanently deletes a message (users.messages.delete).