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::{
17 MSGRAPH_API_BASE, MsgraphSend, MsgraphSendError, MsgraphSendOutput, path_segment,
18 user_path,
19 },
20 },
21};
22
23pub struct MsgraphMailFolderGet {
25 send: MsgraphSend<MsgraphMailFolder>,
26}
27
28impl MsgraphMailFolderGet {
29 pub fn new(auth: &HttpAuthBearer, user_id: &str, id: &str) -> Result<Self, MsgraphSendError> {
32 debug!("prepare microsoft graph mail folder retrieval");
33 trace!("id: {id:?}");
34
35 let user = user_path(user_id)?;
36 let url = Url::parse(MSGRAPH_API_BASE)?
37 .join(&format!("{user}/mailFolders/{}", path_segment(id)?))?;
38 let send = MsgraphSend::get(auth, url);
39
40 Ok(Self { send })
41 }
42}
43
44impl MsgraphCoroutine for MsgraphMailFolderGet {
45 type Yield = MsgraphYield;
46 type Return = Result<MsgraphSendOutput<MsgraphMailFolder>, MsgraphSendError>;
47
48 fn resume(&mut self, arg: Option<&[u8]>) -> MsgraphCoroutineState<Self::Yield, Self::Return> {
49 let out = msgraph_try!(&mut self.send, arg);
50 debug!("mail folder retrieved");
51 trace!("out: {out:?}");
52 MsgraphCoroutineState::Complete(Ok(out))
53 }
54}