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::Patch;

/// PATCH [`Request`] method.
pub trait PatchRequest: Sized {
    /// Request body type.
    type Request: Encodable;

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

    /// Get body of request.
    fn body(&self) -> Self::Request;

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

impl<T: PatchRequest> PatchRequest for &T {
    type Request = T::Request;

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

    fn body(&self) -> Self::Request {
        <T as PatchRequest>::body(self)
    }
}

impl<T: PatchRequest> Request for Patch<T> {
    type Request = T::Request;
    type Response = ();
    type Query = ();

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

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

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

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