pub struct DraftsApi<'a> { /* private fields */ }Expand description
Drafts API façade.
Implementations§
Source§impl<'a> DraftsApi<'a>
impl<'a> DraftsApi<'a>
Sourcepub fn new(client: &'a GmailClient) -> Self
pub fn new(client: &'a GmailClient) -> Self
Wraps an existing GmailClient for draft operations.
Sourcepub async fn list(
&self,
query: Option<&str>,
limit: usize,
page_token: Option<&str>,
) -> Result<DraftListResponse>
pub async fn list( &self, query: Option<&str>, limit: usize, page_token: Option<&str>, ) -> Result<DraftListResponse>
Lists drafts matching query, returning a single page.
query uses the Gmail search-box syntax. limit is rejected
client-side when it exceeds MAX_PAGE_LIMIT; use
Self::list_all to auto-paginate across pages. Needs only the
gmail.readonly scope.
Sourcepub async fn list_all(
&self,
query: Option<&str>,
limit: usize,
) -> Result<DraftListResponse>
pub async fn list_all( &self, query: Option<&str>, limit: usize, ) -> Result<DraftListResponse>
Lists drafts, auto-paginating via cursor as needed.
limit == 0 means “fetch every draft up to
HARD_CAP”, exactly as
MessagesApi::search_all does.
Sourcepub async fn list_summaries(
&self,
query: Option<&str>,
limit: usize,
concurrency: usize,
) -> Result<Vec<DraftSummary>>
pub async fn list_summaries( &self, query: Option<&str>, limit: usize, concurrency: usize, ) -> Result<Vec<DraftSummary>>
Lists drafts and enriches each with its recipients, subject, date
and snippet via one messages.get(format=metadata) call per draft.
The hydration fan-out is MessagesApi::search_summaries’ own
(hydrate_in_order): at most concurrency calls in flight (clamped
to 1 through
MAX_CONCURRENCY),
results in listing order, and any one failure aborts the whole call.
The one exception is a 404 on a draft’s message: the draft was saved
again after the listing, which replaced that message. It keeps its
row, with the listing’s ids and blank headers. Both endpoints accept
gmail.readonly.
Sourcepub async fn get(
&self,
draft_id: &str,
format: MessageFormat,
) -> Result<DraftDetail>
pub async fn get( &self, draft_id: &str, format: MessageFormat, ) -> Result<DraftDetail>
Fetches one draft by its draft id, with its message at format.
A 404 becomes a “no draft with id” error that points at gmail draft list, since the likely cause is passing a message id, which
gmail search and gmail read show but no drafts endpoint accepts.
The HTTP error stays in the chain. Needs only the gmail.readonly
scope.
Sourcepub async fn create(&self, raw: &[u8], thread_id: Option<&str>) -> Result<Draft>
pub async fn create(&self, raw: &[u8], thread_id: Option<&str>) -> Result<Draft>
Creates a draft from a complete RFC 5322 message
(drafts.create?uploadType=multipart).
Uses MessagesApi::insert’s /upload/ multipart transport
([upload_rfc822]), so large attachments work: the draft resource as
the JSON part, then raw verbatim as message/rfc822. Content
over MAX_INSERT_BYTES is refused before the request body is even
built.
thread_id files the draft into an existing thread. Gmail only
honours it when the message’s In-Reply-To/References and
Subject also match that thread (see crate::gmail::compose).
Requires gmail.modify (or gmail.compose); a gmail.readonly
token gets a 403 back from Google. drafts.create costs 10 quota units,
per https://developers.google.com/workspace/gmail/api/reference/quota.
Sourcepub async fn update(
&self,
draft_id: &str,
raw: &[u8],
thread_id: Option<&str>,
) -> Result<Draft>
pub async fn update( &self, draft_id: &str, raw: &[u8], thread_id: Option<&str>, ) -> Result<Draft>
Replaces a draft’s message with raw
(PUT drafts/{id}?uploadType=multipart).
Gmail has no partial form: the whole message is replaced, and the
draft keeps its id but gets a new message id. Same /upload/
transport and MAX_INSERT_BYTES pre-check as Self::create.
thread_id must be re-sent to keep a reply draft in its thread.
An update that omits it silently moves the draft out of the thread,
so callers pass the threadId of the draft they fetched. Drafts have
no ETag or precondition, so this always overwrites whatever is
stored; callers that care check the message id first.
Requires gmail.modify (or gmail.compose).
Trait Implementations§
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for DraftsApi<'a>
impl<'a> !UnwindSafe for DraftsApi<'a>
impl<'a> Freeze for DraftsApi<'a>
impl<'a> Send for DraftsApi<'a>
impl<'a> Sync for DraftsApi<'a>
impl<'a> Unpin for DraftsApi<'a>
impl<'a> UnsafeUnpin for DraftsApi<'a>
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more