io_msgraph/v1/rest/users/mail_folders/
get.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::{
15 rest::users::mail_folders::MsgraphMailFolder,
16 send::{MSGRAPH_API_BASE, MsgraphSend, MsgraphSendError, MsgraphSendOutput, user_path},
17 },
18};
19
20pub struct MsgraphMailFolderGet {
22 send: MsgraphSend<MsgraphMailFolder>,
23}
24
25impl MsgraphMailFolderGet {
26 pub fn new(auth: &HttpAuthBearer, user_id: &str, id: &str) -> Result<Self, MsgraphSendError> {
29 debug!("prepare microsoft graph mail folder retrieval");
30 trace!("id: {id:?}");
31
32 let user = user_path(user_id);
33 let url = Url::parse(MSGRAPH_API_BASE)?.join(&format!("{user}/mailFolders/{id}"))?;
34 let send = MsgraphSend::get(auth, url);
35
36 Ok(Self { send })
37 }
38}
39
40impl MsgraphCoroutine for MsgraphMailFolderGet {
41 type Yield = MsgraphYield;
42 type Return = Result<MsgraphSendOutput<MsgraphMailFolder>, 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!("mail folder retrieved");
47 trace!("out: {out:?}");
48 MsgraphCoroutineState::Complete(Ok(out))
49 }
50}