io_gmail/v1/rest/settings/forwarding_addresses/
delete.rs1use alloc::format;
7
8use io_http::rfc6750::bearer::HttpAuthBearer;
9use log::{debug, trace};
10use url::Url;
11
12use crate::{
13 coroutine::*,
14 gmail_try,
15 v1::send::{GMAIL_API_BASE, GmailNoResponse, GmailSend, GmailSendError, GmailSendOutput},
16};
17
18pub struct GmailForwardingAddressDelete {
21 send: GmailSend<GmailNoResponse>,
22}
23
24impl GmailForwardingAddressDelete {
25 pub fn new(
28 auth: &HttpAuthBearer,
29 user_id: &str,
30 forwarding_email: &str,
31 ) -> Result<Self, GmailSendError> {
32 debug!("prepare gmail forwarding address deletion");
33 trace!("forwarding_email: {forwarding_email:?}");
34
35 let url = Url::parse(GMAIL_API_BASE)?.join(&format!(
36 "users/{user_id}/settings/forwardingAddresses/{forwarding_email}"
37 ))?;
38 let send = GmailSend::delete(auth, url);
39
40 Ok(Self { send })
41 }
42}
43
44impl GmailCoroutine for GmailForwardingAddressDelete {
45 type Yield = GmailYield;
46 type Return = Result<GmailSendOutput<GmailNoResponse>, GmailSendError>;
47
48 fn resume(&mut self, arg: Option<&[u8]>) -> GmailCoroutineState<Self::Yield, Self::Return> {
49 let out = gmail_try!(&mut self.send, arg);
50 debug!("forwarding address deleted");
51 trace!("out: {out:?}");
52 GmailCoroutineState::Complete(Ok(out))
53 }
54}