io_msgraph/v1/rest/users/messages/
delete.rs1use alloc::format;
6
7use io_http::rfc6750::bearer::HttpAuthBearer;
8use log::{debug, trace};
9use url::Url;
10
11use crate::{
12 coroutine::*,
13 msgraph_try,
14 v1::send::{
15 MSGRAPH_API_BASE, MsgraphNoResponse, MsgraphSend, MsgraphSendError, MsgraphSendOutput,
16 path_segment, user_path,
17 },
18};
19
20pub struct MsgraphMessageDelete {
22 send: MsgraphSend<MsgraphNoResponse>,
23}
24
25impl MsgraphMessageDelete {
26 pub fn new(auth: &HttpAuthBearer, user_id: &str, id: &str) -> Result<Self, MsgraphSendError> {
28 debug!("prepare microsoft graph message deletion");
29 trace!("id: {id:?}");
30
31 let user = user_path(user_id)?;
32 let url = Url::parse(MSGRAPH_API_BASE)?
33 .join(&format!("{user}/messages/{}", path_segment(id)?))?;
34 let send = MsgraphSend::delete(auth, url);
35
36 Ok(Self { send })
37 }
38}
39
40impl MsgraphCoroutine for MsgraphMessageDelete {
41 type Yield = MsgraphYield;
42 type Return = Result<MsgraphSendOutput<MsgraphNoResponse>, MsgraphSendError>;
43
44 fn resume(&mut self, arg: Option<&[u8]>) -> MsgraphCoroutineState<Self::Yield, Self::Return> {
45 let out = msgraph_try!(&mut self.send, arg);
46 debug!("message deleted");
47 trace!("out: {out:?}");
48 MsgraphCoroutineState::Complete(Ok(out))
49 }
50}