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 search_messages( &self, account: &str, query: &str, limit: usize, ) -> Result<Vec<Message>, ClientError>

GET /me/messages with $search="<query>" for a given account.

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 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 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 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 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 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, ) -> Result<(), ClientError>

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

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.

Source

pub async fn search_events( &self, account: &str, query: &str, limit: usize, ) -> Result<Vec<Event>, ClientError>

GET /me/events?$search=“”.

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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