use alloc::vec::Vec;
use log::trace;
use url::Url;
use crate::{
coroutine::*,
rfc4918::{
WebdavAuth,
request::WebdavRequest,
send::{SendError, SendOk, SendRaw},
},
};
#[derive(Debug)]
pub struct Move {
state: State,
}
impl Move {
pub fn new(
base_url: &Url,
auth: &WebdavAuth,
user_agent: &str,
path: &str,
destination: &str,
overwrite: bool,
) -> Self {
let request = WebdavRequest::r#move(base_url, auth, user_agent, path)
.destination(destination)
.overwrite(overwrite)
.body(Vec::new());
Self {
state: State::Send(SendRaw::new(request)),
}
}
}
impl WebdavCoroutine for Move {
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::Send(send) => send.resume(arg),
}
}
}
#[derive(Debug)]
enum State {
Send(SendRaw),
}