1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use super::ById;
use crate::request::Endpoint;
use crate::request::HasId;
use crate::request::RequestWithState;
use crate::result::Result;
use reqwest::Method;
use serde::{de::DeserializeOwned, Serialize};
use std::str::FromStr;
use uuid::Uuid;
pub trait Deletable {}
impl<T, S> RequestWithState<T, S>
where
Self: Endpoint + Deletable + ById,
T: Serialize + DeserializeOwned + HasId + Clone,
S: Clone,
{
pub async fn delete_str(self, uuid: &str) -> Result<()> {
self.delete(Uuid::from_str(uuid)?).await
}
pub async fn delete<I>(self, uuid: I) -> Result<()>
where
I: Into<Uuid> + Send,
{
let url = self.by_id_url(uuid)?;
self.client()
.http_builder(Method::DELETE, url)
.send()
.await?
.error_for_status()?;
Ok(())
}
}