io_msgraph/v1/rest/users/mail_folders/
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 user_path,
17 },
18};
19
20pub struct MsgraphMailFolderDelete {
22 send: MsgraphSend<MsgraphNoResponse>,
23}
24
25impl MsgraphMailFolderDelete {
26 pub fn new(auth: &HttpAuthBearer, user_id: &str, id: &str) -> Result<Self, MsgraphSendError> {
28 debug!("prepare microsoft graph mail folder deletion");
29 trace!("id: {id:?}");
30
31 let user = user_path(user_id);
32 let url = Url::parse(MSGRAPH_API_BASE)?.join(&format!("{user}/mailFolders/{id}"))?;
33 let send = MsgraphSend::delete(auth, url);
34
35 Ok(Self { send })
36 }
37}
38
39impl MsgraphCoroutine for MsgraphMailFolderDelete {
40 type Yield = MsgraphYield;
41 type Return = Result<MsgraphSendOutput<MsgraphNoResponse>, MsgraphSendError>;
42
43 fn resume(&mut self, arg: Option<&[u8]>) -> MsgraphCoroutineState<Self::Yield, Self::Return> {
44 let out = msgraph_try!(&mut self.send, arg);
45 debug!("mail folder deleted");
46 trace!("out: {out:?}");
47 MsgraphCoroutineState::Complete(Ok(out))
48 }
49}