use alloc::vec::Vec;
use log::trace;
use url::Url;
use crate::{
coroutine::*,
rfc4791::calendar::join_path,
rfc4918::{
WebdavAuth,
delete::Delete,
send::{SendError, SendOk},
},
};
#[derive(Debug)]
pub struct DeleteCalendar {
state: State,
}
impl DeleteCalendar {
pub fn new(
base_url: &Url,
auth: &WebdavAuth,
user_agent: &str,
home_set_path: &str,
calendar_id: &str,
) -> Self {
let path = join_path(home_set_path, calendar_id);
Self {
state: State::Delete(Delete::new(base_url, auth, user_agent, &path, None)),
}
}
}
impl WebdavCoroutine for DeleteCalendar {
type Yield = WebdavYield;
type Return = Result<SendOk<Vec<u8>>, SendError>;
fn resume(&mut self, arg: Option<&[u8]>) -> WebdavCoroutineState<Self::Yield, Self::Return> {
trace!("sending request");
match &mut self.state {
State::Delete(delete) => delete.resume(arg),
}
}
}
#[derive(Debug)]
enum State {
Delete(Delete),
}