push new dir

This commit is contained in:
grimhilt
2023-06-25 17:27:11 +02:00
parent a1aeb65600
commit b07e3062b7
7 changed files with 108 additions and 40 deletions

View File

@@ -6,21 +6,27 @@ pub struct CreateFolder {
}
impl CreateFolder {
pub fn new<U: IntoUrl>(url: U) -> Self {
ListFolders {
api_builder: ApiBuilder::new()
.set_request(Method::from_bytes(b"MKCOL").unwrap(), url),
pub fn new() -> Self {
CreateFolder {
api_builder: ApiBuilder::new(),
}
}
pub fn set_url(&mut self, url: &str) -> &mut CreateFolder {
self.api_builder.build_request(Method::from_bytes(b"MKCOL").unwrap(), url);
self
}
pub async fn send(&mut self) -> Result<Response, Error> {
self.api_builder.send().await
}
pub async fn send_with_err(mut self) -> Result<(), ApiError> {
let res = self.send().await.map_err(ApiError::RequestError)?;
pub fn send_with_err(&mut self) -> Result<(), ApiError> {
let res = tokio::runtime::Runtime::new().unwrap().block_on(async {
self.send().await
}).map_err(ApiError::RequestError)?;
if res.status().is_success() {
Ok()
Ok(())
} else {
Err(ApiError::IncorrectRequest(res))
}