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
44
45
46
47
48
49
50
51
use super::*;
use crate::methods::Delete;

/// DELETE [`Request`] method.
pub trait DeleteRequest: Sized {
    /// Query type to use.
    type Query: ToQuery;

    /// Get path of request.
    fn path(&self) -> Cow<'_, str>;

    /// Get query of request.
    fn query(&self) -> Self::Query;

    /// Turn self into a [`Request`].
    fn request(self) -> Delete<Self> {
        self.into()
    }
}

impl<T: DeleteRequest> DeleteRequest for &T {
    type Query = T::Query;

    fn path(&self) -> Cow<'_, str> {
        <T as DeleteRequest>::path(self)
    }

    fn query(&self) -> Self::Query {
        <T as DeleteRequest>::query(self)
    }
}

impl<T: DeleteRequest> Request for Delete<T> {
    type Request = ();
    type Response = ();
    type Query = T::Query;

    fn path(&self) -> Cow<'_, str> {
        self.inner.path()
    }

    fn body(&self) -> Self::Request {}

    fn query(&self) -> Self::Query {
        self.inner.query()
    }

    fn method(&self) -> Method {
        Method::Delete
    }
}