io_gmail/v1/rest/users/
stop.rs1use alloc::{format, vec::Vec};
6
7use io_http::rfc6750::bearer::HttpAuthBearer;
8use log::{debug, trace};
9use url::Url;
10
11use crate::{
12 coroutine::*,
13 gmail_try,
14 v1::send::{GMAIL_API_BASE, GmailNoResponse, GmailSend, GmailSendError, GmailSendOutput},
15};
16
17pub struct GmailStop {
19 send: GmailSend<GmailNoResponse>,
20}
21
22impl GmailStop {
23 pub fn new(auth: &HttpAuthBearer, user_id: &str) -> Result<Self, GmailSendError> {
26 debug!("prepare gmail watch stop");
27 trace!("user_id: {user_id:?}");
28
29 let url = Url::parse(GMAIL_API_BASE)?.join(&format!("users/{user_id}/stop"))?;
30 let send = GmailSend::with_method(auth, "POST", url, None, Vec::new());
31
32 Ok(Self { send })
33 }
34}
35
36impl GmailCoroutine for GmailStop {
37 type Yield = GmailYield;
38 type Return = Result<GmailSendOutput<GmailNoResponse>, GmailSendError>;
39
40 fn resume(&mut self, arg: Option<&[u8]>) -> GmailCoroutineState<Self::Yield, Self::Return> {
41 let out = gmail_try!(&mut self.send, arg);
42 debug!("watch stopped");
43 trace!("out: {out:?}");
44 GmailCoroutineState::Complete(Ok(out))
45 }
46}