Skip to main content

GraphClient

Struct GraphClient 

Source
pub struct GraphClient { /* private fields */ }
Expand description

Stateful Microsoft Graph client. Holds an AuthClient and a shared HTTP client.

Implementations§

Source§

impl GraphClient

Source

pub fn new(auth: AuthClient) -> Result<Self, ClientError>

Source

pub fn for_test(auth: AuthClient, base_url: impl Into<String>) -> Self

Source

pub fn auth(&self) -> &AuthClient

Source

pub async fn me(&self, access_token: &str) -> Result<Me, ClientError>

GET /me. Used right after sign-in to learn the user’s email.

Source

pub async fn list_inbox( &self, account: &str, limit: usize, skip: usize, unread_only: bool, ) -> Result<InboxPage, ClientError>

GET /me/mailFolders/inbox/messages for a given account email. Acquires/refreshes a token transparently via AuthClient::get_valid_token.

Source

pub async fn list_folder( &self, account: &str, folder_id: &str, limit: usize, skip: usize, unread_only: bool, ) -> Result<InboxPage, ClientError>

GET /me/mailFolders/{folder_id}/messages: list a custom folder.

Source

pub async fn mail_delta_bootstrap( &self, account: &str, folder: &str, ) -> Result<(Vec<Message>, String), ClientError>

GET /me/messages with $search="<query>" for a given account. Bootstrap a mail delta stream for a folder: (current messages, deltaLink).

Source

pub async fn mail_delta( &self, account: &str, delta_link: &str, ) -> Result<(Vec<MailDeltaEvent>, String), ClientError>

Poll a mail deltaLink for changes.

Source

pub async fn calendar_delta_bootstrap( &self, account: &str, start: DateTime<Utc>, end: DateTime<Utc>, ) -> Result<(Vec<Event>, String), ClientError>

Bootstrap a calendar delta stream over a window: (current events, deltaLink).

Source

pub async fn calendar_delta( &self, account: &str, delta_link: &str, ) -> Result<(Vec<CalendarDeltaEvent>, String), ClientError>

Poll a calendar deltaLink for changes.

Source

pub async fn batch_all( &self, account: &str, requests: Vec<BatchRequest>, ) -> Result<Vec<BatchResponse>, ClientError>

Run a set of batch sub-requests for one account.

Source

pub async fn list_conversation( &self, account: &str, conversation_id: &str, ) -> Result<Vec<Message>, ClientError>

Fetch every message in a conversation (thread), oldest first.

Source

pub async fn list_messages_at( &self, account: &str, url: &str, ) -> Result<InboxPage, ClientError>

Fetch a page of messages at an absolute Graph continuation URL.

Source

pub async fn search_messages( &self, account: &str, query: &str, limit: usize, ) -> Result<InboxPage, ClientError>

Source

pub async fn search_folder( &self, account: &str, folder: &str, query: &str, limit: usize, ) -> Result<InboxPage, ClientError>

$search within one folder (well-known name or folder id).

Source

pub async fn mark_unread( &self, account: &str, message_id: &str, ) -> Result<(), ClientError>

PATCH /me/messages/{id} with { "isRead": false }.

Source

pub async fn set_flag( &self, account: &str, message_id: &str, flagged: bool, ) -> Result<(), ClientError>

PATCH /me/messages/{id} with { "flag": { "flagStatus": "flagged"|"notFlagged" } }.

Source

pub async fn get_categories( &self, account: &str, message_id: &str, ) -> Result<Vec<String>, ClientError>

GET /me/messages/{id}?$select=categories.

Source

pub async fn set_categories( &self, account: &str, message_id: &str, categories: &[String], ) -> Result<(), ClientError>

PATCH /me/messages/{id} categories.

Source

pub async fn move_message( &self, account: &str, message_id: &str, destination: &str, ) -> Result<(), ClientError>

POST /me/messages/{id}/move: move to a folder by ID or well-known name.

Source

pub async fn list_mail_folders( &self, account: &str, ) -> Result<Vec<MailFolder>, ClientError>

GET /me/mailFolders: list the account’s top-level folders.

Source

pub async fn create_mail_folder( &self, account: &str, display_name: &str, ) -> Result<MailFolder, ClientError>

POST /me/mailFolders: create a top-level folder, returning it.

Source

pub async fn list_child_folders( &self, account: &str, parent_id: &str, ) -> Result<Vec<MailFolder>, ClientError>

GET /me/mailFolders/{parent_id}/childFolders: list a folder’s children.

Source

pub async fn create_child_folder( &self, account: &str, parent_id: &str, display_name: &str, ) -> Result<MailFolder, ClientError>

POST /me/mailFolders/{parent_id}/childFolders: create a child folder.

Source

pub async fn delete_mail_folder( &self, account: &str, folder_id: &str, ) -> Result<(), ClientError>

DELETE /me/mailFolders/{id}: delete a folder (contents move to Deleted Items).

Source

pub async fn send_mail( &self, account: &str, message: &Outgoing, ) -> Result<(), ClientError>

POST /me/sendMail: compose-and-send a new message.

Source

pub async fn reply_message( &self, account: &str, message_id: &str, comment: &str, ) -> Result<(), ClientError>

POST /me/messages/{id}/reply.

Source

pub async fn reply_all_message( &self, account: &str, message_id: &str, comment: &str, ) -> Result<(), ClientError>

POST /me/messages/{id}/replyAll.

Source

pub async fn forward_message( &self, account: &str, message_id: &str, to: &[String], comment: &str, ) -> Result<(), ClientError>

POST /me/messages/{id}/forward.

Source

pub async fn list_drafts( &self, account: &str, limit: usize, skip: usize, ) -> Result<InboxPage, ClientError>

GET /me/mailFolders/drafts/messages.

Source

pub async fn create_draft( &self, account: &str, message: &Outgoing, ) -> Result<String, ClientError>

POST /me/messages: create a draft, returning its new message ID.

Source

pub async fn create_reply_draft( &self, account: &str, message_id: &str, comment: &str, ) -> Result<String, ClientError>

POST /me/messages/{id}/createReply.

Source

pub async fn create_reply_all_draft( &self, account: &str, message_id: &str, comment: &str, ) -> Result<String, ClientError>

POST /me/messages/{id}/createReplyAll.

Source

pub async fn create_forward_draft( &self, account: &str, message_id: &str, to: &[String], comment: &str, ) -> Result<String, ClientError>

POST /me/messages/{id}/createForward.

Source

pub async fn send_draft( &self, account: &str, message_id: &str, ) -> Result<(), ClientError>

POST /me/messages/{id}/send: send an existing draft.

Source

pub async fn update_draft( &self, account: &str, message_id: &str, message: &Outgoing, ) -> Result<(), ClientError>

PATCH /me/messages/{id}: overwrite a draft’s editable fields.

Source

pub async fn update_draft_recipients( &self, account: &str, message_id: &str, to: Option<&[String]>, cc: Option<&[String]>, bcc: Option<&[String]>, ) -> Result<(), ClientError>

PATCH /me/messages/{id}: replace only the given recipient lists.

Source

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

DELETE /me/messages/{id}: moves to Deleted Items. Works for both drafts and inbox messages.

Source

pub async fn add_attachment( &self, account: &str, message_id: &str, name: &str, content_type: &str, bytes: &[u8], ) -> Result<String, ClientError>

POST /me/messages/{id}/attachments: attach a file (simple upload).

Source

pub async fn delete_attachment( &self, account: &str, message_id: &str, attachment_id: &str, ) -> Result<(), ClientError>

DELETE /me/messages/{id}/attachments/{att_id}.

Source

pub async fn get_message( &self, account: &str, message_id: &str, ) -> Result<FullMessage, ClientError>

GET /me/messages/{id} for a given account email.

Source

pub async fn fetch_message_headers( &self, account: &str, message_id: &str, ) -> Result<Vec<(String, String)>, ClientError>

GET /me/messages/{id}?$select=internetMessageHeaders.

Source

pub async fn list_attachments( &self, account: &str, message_id: &str, ) -> Result<Vec<Attachment>, ClientError>

GET /me/messages/{id}/attachments.

Source

pub async fn unsubscribe_one_click(&self, url: &str) -> Result<(), ClientError>

POST a List-Unsubscribe=One-Click form body (RFC 8058) to a third-party unsubscribe URL. No bearer token; the URL belongs to the sender, not Microsoft.

Only https to a public host; see mail::unsubscribe_one_click. A Self::for_test client also reaches a loopback mock server.

Source

pub async fn list_people( &self, account: &str, top: usize, ) -> Result<Vec<Person>, ClientError>

GET /me/people?$top={top}&$select=displayName,scoredEmailAddresses: Outlook’s ranked “people I interact with” list.

Source

pub async fn get_attachment_bytes( &self, account: &str, message_id: &str, attachment_id: &str, ) -> Result<Vec<u8>, ClientError>

GET /me/messages/{id}/attachments/{att_id} returning decoded bytes.

Source

pub async fn mark_read( &self, account: &str, message_id: &str, ) -> Result<(), ClientError>

PATCH /me/messages/{id} with isRead: true.

Source

pub async fn list_calendars( &self, account: &str, ) -> Result<Vec<Calendar>, ClientError>

GET /me/calendars.

Source

pub async fn list_calendar_view( &self, account: &str, calendar_id: Option<&str>, start: DateTime<Utc>, end: DateTime<Utc>, limit: usize, ) -> Result<EventsPage, ClientError>

GET /me/calendarView (or /me/calendars/{id}/calendarView).

Source

pub async fn list_events_at( &self, account: &str, url: &str, ) -> Result<EventsPage, ClientError>

Fetch a page of calendar events at an absolute Graph continuation URL.

Source

pub async fn get_event( &self, account: &str, event_id: &str, ) -> Result<Event, ClientError>

GET /me/events/{id}.

Source

pub async fn create_event( &self, account: &str, calendar_id: Option<&str>, new_event: &NewEvent, ) -> Result<String, ClientError>

POST /me/calendar/events (or /me/calendars/{id}/events).

Source

pub async fn update_event( &self, account: &str, event_id: &str, new_event: &NewEvent, ) -> Result<(), ClientError>

PATCH /me/events/{id}: overwrite editable fields.

Source

pub async fn move_time( &self, account: &str, event_id: &str, start: DateTime<Utc>, end: DateTime<Utc>, tz: &str, ) -> Result<(), ClientError>

PATCH /me/events/{id}: change only start + end.

Source

pub async fn delete_event( &self, account: &str, event_id: &str, ) -> Result<(), ClientError>

DELETE /me/events/{id}: silent removal.

Source

pub async fn cancel_event( &self, account: &str, event_id: &str, comment: &str, ) -> Result<(), ClientError>

POST /me/events/{id}/cancel: organizer-only.

Source

pub async fn rsvp_event( &self, account: &str, event_id: &str, kind: RsvpKind, comment: &str, send_response: bool, proposed: Option<&ProposedTime>, ) -> Result<(), ClientError>

POST /me/events/{id}/accept | /tentativelyAccept | /decline.

proposed carries a counter-proposed time; Graph only honors it on tentativelyAccept and decline (ignored for Accept).

Source

pub async fn move_event_to_calendar( &self, account: &str, event_id: &str, destination_calendar_id: &str, ) -> Result<(), ClientError>

PATCH /me/events/{id} with calendar@odata.bind: move between calendars.

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> 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, 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