Skip to main content

Scoped

Struct Scoped 

Source
pub struct Scoped<'c, S> { /* private fields */ }
Expand description

A Client bound to a Scope. Returned by Client::org, Client::inbox, and Client::pod; the resource methods it exposes depend on which capability traits the scope S implements.

Implementations§

Source§

impl<S: AccountScopes> Scoped<'_, S>

Accounts can also be listed through an inbox or pod handle; writes stay org-only.

Source

pub async fn list_accounts(&self, page: Page) -> Result<AccountList, Error>

GET {scope}/accounts, accounts connected through that inbox or pod.

Source

pub async fn get_account(&self, account_id: &str) -> Result<Account, Error>

GET {scope}/accounts/{account_id}.

Source§

impl<S: ApiKeys> Scoped<'_, S>

Source

pub async fn create_api_key( &self, key: CreateApiKey, ) -> Result<CreatedApiKey, Error>

POST {scope}/api-keys, mint a new API key. The full secret is in CreatedApiKey::api_key and is shown only here; store it now.

Source

pub async fn list_api_keys(&self, page: Page) -> Result<ApiKeyList, Error>

GET {scope}/api-keys, one page.

Source

pub async fn list_all_api_keys(&self) -> Result<Vec<ApiKey>, Error>

Every API key, draining pagination.

Source

pub async fn delete_api_key(&self, api_key_id: &str) -> Result<(), Error>

DELETE {scope}/api-keys/{api_key_id}.

Source

pub async fn update_api_key( &self, api_key_id: &str, update: UpdateApiKey, ) -> Result<ApiKey, Error>

PATCH {scope}/api-keys/{api_key_id}, rename the key and/or replace its permission set.

Source§

impl Scoped<'_, OrgScope>

Single-key reads exist only at the organization scope.

Source

pub async fn get_api_key(&self, api_key_id: &str) -> Result<ApiKey, Error>

GET /v0/api-keys/{api_key_id}. The inbox and pod scopes expose create/list/update/delete for their keys but no per-key read.

Source§

impl Scoped<'_, InboxScope<'_>>

The inbox’s calendar. Every calendar endpoint is inbox-scoped; writes take an optional etag (from a prior read) for optimistic concurrency, and the API answers 428 when a newer revision exists.

Source

pub async fn get_calendar( &self, consistency: Option<Consistency>, ) -> Result<Calendar, Error>

GET {base}/calendar, the inbox’s calendar settings.

Source

pub async fn update_calendar( &self, timezone: &str, etag: Option<&str>, ) -> Result<Calendar, Error>

PATCH {base}/calendar, move the calendar to another IANA timezone. Pass the etag from a prior read to reject concurrent edits.

Source

pub async fn get_agenda( &self, query: CalendarEventsQuery, ) -> Result<CalendarEventList, Error>

GET {base}/calendar/agenda, occurrences in a window, flattened: recurring series appear as their individual instances.

Source

pub async fn list_all_agenda( &self, query: CalendarEventsQuery, ) -> Result<Vec<CalendarEvent>, Error>

Every occurrence in the query’s window, draining pagination.

Source

pub async fn list_calendar_events( &self, page: Page, ) -> Result<CalendarEventList, Error>

GET {base}/calendar/events, one page of the calendar’s stored events (series stay unexpanded; use the agenda for flattened occurrences).

Source

pub async fn list_all_calendar_events( &self, ) -> Result<Vec<CalendarEvent>, Error>

Every stored event, draining pagination.

Source

pub async fn create_calendar_event( &self, event: CreateCalendarEvent, ) -> Result<CalendarEventMutation, Error>

POST {base}/calendar/events, create an event (or series, with a recurrence rule).

Source

pub async fn get_calendar_event( &self, event_id: &str, consistency: Option<Consistency>, ) -> Result<CalendarEvent, Error>

GET {base}/calendar/events/{event_id}.

Source

pub async fn update_calendar_event( &self, event_id: &str, update: UpdateCalendarEvent, mode: Option<MutationMode>, etag: Option<&str>, ) -> Result<CalendarEventMutation, Error>

PATCH {base}/calendar/events/{event_id}. On a series instance, pass mode to move just that occurrence or it and every later one.

Source

pub async fn delete_calendar_event( &self, event_id: &str, mode: Option<MutationMode>, send_invites: Option<bool>, etag: Option<&str>, ) -> Result<DeleteCalendarEventResult, Error>

DELETE {base}/calendar/events/{event_id}. On a series instance, mode picks between cancelling just that occurrence and every future one.

Source

pub async fn list_calendar_event_instances( &self, event_id: &str, query: CalendarEventsQuery, ) -> Result<CalendarEventList, Error>

GET {base}/calendar/events/{event_id}/instances, the occurrences of a recurring event in a window.

Source

pub async fn list_all_calendar_event_instances( &self, event_id: &str, query: CalendarEventsQuery, ) -> Result<Vec<CalendarEvent>, Error>

Every instance of a recurring event in the query’s window, draining pagination.

Source

pub async fn respond_to_calendar_event( &self, event_id: &str, respond: RespondToCalendarEvent, etag: Option<&str>, ) -> Result<CalendarEventMutation, Error>

POST {base}/calendar/events/{event_id}/respond, reply to an invite on behalf of this inbox.

Source§

impl<S: Domains> Scoped<'_, S>

Source

pub async fn create_domain(&self, domain: CreateDomain) -> Result<Domain, Error>

POST {scope}/domains, add a sending domain. The response carries the DNS VerificationRecords to publish.

Source

pub async fn list_domains(&self, page: Page) -> Result<DomainList, Error>

GET {scope}/domains, one page.

Source

pub async fn list_all_domains(&self) -> Result<Vec<Domain>, Error>

Every domain, draining pagination.

Source

pub async fn get_domain(&self, domain_id: &str) -> Result<Domain, Error>

GET {scope}/domains/{domain_id}.

Source

pub async fn update_domain( &self, domain_id: &str, update: UpdateDomain, ) -> Result<Domain, Error>

PATCH {scope}/domains/{domain_id}, toggle feedback and subdomain settings.

Source

pub async fn delete_domain(&self, domain_id: &str) -> Result<(), Error>

DELETE {scope}/domains/{domain_id}.

Source

pub async fn verify_domain(&self, domain_id: &str) -> Result<(), Error>

POST {scope}/domains/{domain_id}/verify, ask the API to re-check the DNS records; poll Scoped::get_domain for the resulting status.

Source

pub async fn get_domain_zone_file( &self, domain_id: &str, ) -> Result<String, Error>

GET {scope}/domains/{domain_id}/zone-file, the DNS records as a ready-to-import zone file (plain text, not JSON).

Source§

impl Scoped<'_, OrgScope>

Provider setup links exist only at the organization scope.

GET /v0/domains/{domain_id}/setup-link, a one-click DNS setup flow for the domain’s provider, when one is DomainSetupLink::supported.

Source§

impl<S: Drafts> Scoped<'_, S>

Source

pub async fn list_drafts(&self, page: Page) -> Result<DraftList, Error>

GET {scope}/drafts, one page. Drafts are readable at every scope but only created and sent from an Client::inbox.

Source

pub async fn list_all_drafts(&self) -> Result<Vec<Draft>, Error>

Every draft, draining pagination.

Source

pub async fn get_draft(&self, draft_id: &str) -> Result<Draft, Error>

GET {scope}/drafts/{draft_id}.

Source

pub async fn get_draft_attachment( &self, draft_id: &str, attachment_id: &str, ) -> Result<Attachment, Error>

GET {scope}/drafts/{draft_id}/attachments/{attachment_id}.

Source§

impl Scoped<'_, InboxScope<'_>>

Source

pub async fn create_draft(&self, draft: CreateDraft) -> Result<Draft, Error>

POST /v0/inboxes/{inbox_id}/drafts, create a draft. Supply in_reply_to to create a reply draft (with reply_all to address the whole thread) or forward_of to create a forward draft.

Source

pub async fn update_draft( &self, draft_id: &str, update: UpdateDraft, ) -> Result<Draft, Error>

PATCH /v0/inboxes/{inbox_id}/drafts/{draft_id}, edit an existing draft.

Source

pub async fn delete_draft(&self, draft_id: &str) -> Result<(), Error>

DELETE /v0/inboxes/{inbox_id}/drafts/{draft_id}.

Source

pub async fn send_draft(&self, draft_id: &str) -> Result<SentMessage, Error>

POST /v0/inboxes/{inbox_id}/drafts/{draft_id}/send, send a draft. The draft is deleted after a successful send.

Source§

impl Scoped<'_, InboxScope<'_>>

Source

pub async fn list_events(&self, page: Page) -> Result<InboxEventList, Error>

GET /v0/inboxes/{inbox_id}/events, one page of the inbox’s audit log.

Source

pub async fn list_all_events(&self) -> Result<Vec<InboxEvent>, Error>

Every inbox event, draining pagination.

Source§

impl<S: Inboxes> Scoped<'_, S>

Source

pub async fn create_inbox(&self, inbox: CreateInbox) -> Result<Inbox, Error>

POST {scope}/inboxes, a new agent-owned email address. At Client::org this creates a standalone inbox; at Client::pod it creates the inbox inside that pod. Free plans get {username}@agentmail.to; custom domains must be verified first.

Source

pub async fn list_inboxes(&self, page: Page) -> Result<InboxList, Error>

GET {scope}/inboxes, one page.

Source

pub async fn list_all_inboxes(&self) -> Result<Vec<Inbox>, Error>

Every inbox in the scope, draining pagination.

Source

pub async fn get_inbox(&self, inbox_id: &str) -> Result<Inbox, Error>

GET {scope}/inboxes/{inbox_id}.

Source

pub async fn update_inbox( &self, inbox_id: &str, update: UpdateInbox, ) -> Result<Inbox, Error>

PATCH {scope}/inboxes/{inbox_id}, update display name and/or metadata.

Source

pub async fn delete_inbox(&self, inbox_id: &str) -> Result<(), Error>

DELETE {scope}/inboxes/{inbox_id}.

Source

pub async fn search_inboxes( &self, q: &str, page: Page, ) -> Result<InboxList, Error>

GET {scope}/inboxes/search, full-text search over the scope’s inboxes (display name, address, metadata).

Source

pub async fn list_all_matching_inboxes( &self, q: &str, ) -> Result<Vec<Inbox>, Error>

Every inbox matching q, draining pagination.

Source§

impl Scoped<'_, InboxScope<'_>>

Source

pub async fn authorize( &self, authorize: AuthorizeInbox, ) -> Result<AuthorizeInboxResult, Error>

POST /v0/inboxes/{inbox_id}/authorize, complete the browser authorization flow for this inbox: the human approves in their browser, and this call exchanges the resulting auth_token for a scoped API key (AuthorizeInboxResult::api_key_id).

Source§

impl<S: Lists> Scoped<'_, S>

Source

pub async fn list_entries( &self, direction: ListDirection, kind: ListKind, page: Page, ) -> Result<ListEntries, Error>

GET {scope}/lists/{direction}/{kind}, one page of entries.

Source

pub async fn list_all_entries( &self, direction: ListDirection, kind: ListKind, ) -> Result<Vec<ListEntry>, Error>

Every entry in the list, draining pagination.

Source

pub async fn create_list_entry( &self, direction: ListDirection, kind: ListKind, entry: CreateListEntry, ) -> Result<ListEntry, Error>

POST {scope}/lists/{direction}/{kind}, add an address or domain.

Source

pub async fn get_list_entry( &self, direction: ListDirection, kind: ListKind, entry: &str, ) -> Result<ListEntry, Error>

GET {scope}/lists/{direction}/{kind}/{entry}.

Source

pub async fn delete_list_entry( &self, direction: ListDirection, kind: ListKind, entry: &str, ) -> Result<(), Error>

DELETE {scope}/lists/{direction}/{kind}/{entry}.

Source§

impl Scoped<'_, InboxScope<'_>>

Messages exist only within an inbox, so these methods live on client.inbox(id).

Source

pub async fn send_message( &self, message: SendMessage, ) -> Result<SentMessage, Error>

POST /v0/inboxes/{inbox_id}/messages/send.

Source

pub async fn send_text( &self, to: &str, subject: &str, text: &str, ) -> Result<SentMessage, Error>

Send a plain-text message to a single recipient: the common case, in one line. For anything richer (HTML, cc/bcc, attachments, labels), build a SendMessage and call Scoped::send_message.

Source

pub async fn list_messages( &self, filters: MessageListFilters, ) -> Result<MessageList, Error>

GET /v0/inboxes/{inbox_id}/messages, one page. Pass MessageListFilters::default for the first unfiltered page.

Source

pub async fn list_all_messages( &self, filters: MessageListFilters, ) -> Result<Vec<Message>, Error>

Every message matching filters, draining pagination.

Source

pub async fn search_messages( &self, query: &str, filters: MessageListFilters, ) -> Result<MessageList, Error>

GET /v0/inboxes/{inbox_id}/messages/search (q required).

Source

pub async fn search_all_messages( &self, query: &str, filters: MessageListFilters, ) -> Result<Vec<Message>, Error>

Every message matching a search, draining pagination.

Source

pub async fn get_message(&self, message_id: &str) -> Result<Message, Error>

GET /v0/inboxes/{inbox_id}/messages/{message_id}.

Source

pub async fn update_message( &self, message_id: &str, update: UpdateMessage, ) -> Result<UpdatedMessage, Error>

PATCH /v0/inboxes/{inbox_id}/messages/{message_id}, add/remove labels (read state is a label). Returns the id and labels after the change.

Source

pub async fn delete_message(&self, message_id: &str) -> Result<(), Error>

DELETE /v0/inboxes/{inbox_id}/messages/{message_id}.

Source

pub async fn reply_to_message( &self, message_id: &str, reply: ReplyToMessage, ) -> Result<SentMessage, Error>

POST /v0/inboxes/{inbox_id}/messages/{message_id}/reply, reply to a message (recipients derived from the parent).

Source

pub async fn reply_all_to_message( &self, message_id: &str, reply: ReplyToMessage, ) -> Result<SentMessage, Error>

POST /v0/inboxes/{inbox_id}/messages/{message_id}/reply-all.

Source

pub async fn forward_message( &self, message_id: &str, message: SendMessage, ) -> Result<SentMessage, Error>

POST /v0/inboxes/{inbox_id}/messages/{message_id}/forward. Reuses SendMessage for the new recipients and any added body.

Source

pub async fn get_raw_message( &self, message_id: &str, ) -> Result<RawMessage, Error>

GET /v0/inboxes/{inbox_id}/messages/{message_id}/raw, a presigned URL for the raw RFC 822 (.eml) source; fetch the bytes with Client::download_raw.

Source

pub async fn get_message_attachment( &self, message_id: &str, attachment_id: &str, ) -> Result<Attachment, Error>

GET /v0/inboxes/{inbox_id}/messages/{message_id}/attachments/{attachment_id}.

Source

pub async fn batch_get_messages( &self, message_ids: Vec<String>, ) -> Result<BatchGetMessagesResponse, Error>

POST /v0/inboxes/{inbox_id}/messages/batch-get, fetch many messages by id in one call.

Source

pub async fn batch_update_messages( &self, update: BatchUpdateMessages, ) -> Result<BatchUpdateMessagesResponse, Error>

POST /v0/inboxes/{inbox_id}/messages/batch-update, apply the same label changes to many messages at once.

Source§

impl<S: Metrics> Scoped<'_, S>

Source

pub async fn get_metrics_events( &self, query: MetricsQuery, ) -> Result<MetricsEvents, Error>

GET {scope}/metrics/events, event counts bucketed over time, keyed by event type.

Source

pub async fn get_metrics_usage( &self, query: MetricsQuery, ) -> Result<MetricsUsage, Error>

GET {scope}/metrics/usage, usage values bucketed over time, keyed by usage type.

Source

pub async fn get_metrics_rates( &self, query: MetricsQuery, ) -> Result<MetricsRates, Error>

GET {scope}/metrics/rates, bounce/complaint rates bucketed over time, keyed by rate type. Set MetricsQuery::window to pick the window each rate is computed over.

Source§

impl<S: Threads> Scoped<'_, S>

Source

pub async fn list_threads( &self, filters: ThreadListFilters, ) -> Result<ThreadList, Error>

GET {scope}/threads, one page. Pass ThreadListFilters::default for the first unfiltered page; carry next_page_token back in for more, or use Scoped::list_all_threads to drain every page.

Source

pub async fn list_all_threads( &self, filters: ThreadListFilters, ) -> Result<Vec<Thread>, Error>

Every thread matching filters, draining pagination.

Source

pub async fn search_threads( &self, query: &str, filters: ThreadListFilters, ) -> Result<ThreadList, Error>

GET {scope}/threads/search, full-text search (q required); matches come back in Thread::highlights.

Source

pub async fn search_all_threads( &self, query: &str, filters: ThreadListFilters, ) -> Result<Vec<Thread>, Error>

Every thread matching a search, draining pagination.

Source

pub async fn get_thread(&self, thread_id: &str) -> Result<Thread, Error>

GET {scope}/threads/{thread_id}, the full thread with its messages.

Source

pub async fn update_thread( &self, thread_id: &str, update: UpdateThread, ) -> Result<UpdatedThread, Error>

PATCH {scope}/threads/{thread_id}, add and/or remove labels across the thread. Returns the thread id and its labels after the change.

Source

pub async fn delete_thread(&self, thread_id: &str) -> Result<(), Error>

DELETE {scope}/threads/{thread_id}.

Source

pub async fn get_thread_attachment( &self, thread_id: &str, attachment_id: &str, ) -> Result<Attachment, Error>

GET {scope}/threads/{thread_id}/attachments/{attachment_id}, the attachment metadata with a short-lived download_url; fetch the bytes with Client::download_attachment.

Source§

impl<S: Webhooks> Scoped<'_, S>

Source

pub async fn create_webhook( &self, webhook: CreateWebhook, ) -> Result<Webhook, Error>

POST {scope}/webhooks, subscribe an HTTPS endpoint to events (e.g. message.received). The response carries the signing secret exactly once; store it. Inbox and pod scopes ignore inbox_ids/pod_ids (the scope already targets the delivery); set those only at Client::org.

Source

pub async fn list_webhooks(&self, page: Page) -> Result<WebhookList, Error>

GET {scope}/webhooks, one page.

Source

pub async fn list_all_webhooks(&self) -> Result<Vec<Webhook>, Error>

Every webhook, draining pagination.

Source

pub async fn get_webhook(&self, webhook_id: &str) -> Result<Webhook, Error>

GET {scope}/webhooks/{webhook_id}.

Source

pub async fn update_webhook( &self, webhook_id: &str, update: UpdateWebhook, ) -> Result<Webhook, Error>

PATCH {scope}/webhooks/{webhook_id}, edit event types and inbox/pod targeting (see UpdateWebhook).

Source

pub async fn delete_webhook(&self, webhook_id: &str) -> Result<(), Error>

DELETE {scope}/webhooks/{webhook_id}.

Source

pub async fn get_webhook_headers( &self, webhook_id: &str, ) -> Result<WebhookHeaderNames, Error>

GET {scope}/webhooks/{webhook_id}/headers, the names of the extra headers sent with each delivery (values are never returned).

Source

pub async fn update_webhook_headers( &self, webhook_id: &str, update: UpdateWebhookHeaders, ) -> Result<(), Error>

PATCH {scope}/webhooks/{webhook_id}/headers, set/replace headers and remove others by name. Responds 204 with no body.

Trait Implementations§

Source§

impl<'c, S: Clone> Clone for Scoped<'c, S>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'c, S: Copy> Copy for Scoped<'c, S>

Source§

impl<'c, S: Debug> Debug for Scoped<'c, S>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'c, S> !RefUnwindSafe for Scoped<'c, S>

§

impl<'c, S> !UnwindSafe for Scoped<'c, S>

§

impl<'c, S> Freeze for Scoped<'c, S>
where S: Freeze,

§

impl<'c, S> Send for Scoped<'c, S>
where S: Send,

§

impl<'c, S> Sync for Scoped<'c, S>
where S: Sync,

§

impl<'c, S> Unpin for Scoped<'c, S>
where S: Unpin,

§

impl<'c, S> UnsafeUnpin for Scoped<'c, S>
where S: UnsafeUnpin,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more