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
52
53
54
use hyper::Method as HyperMethod;
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub enum HttpMethod {
Head,
Get,
Post,
Put,
Delete,
Connect,
Options,
Patch,
Trace,
Custom(&'static str),
}
impl Into<HyperMethod> for HttpMethod {
fn into(self) -> HyperMethod {
match self {
HttpMethod::Connect => HyperMethod::Connect,
HttpMethod::Delete => HyperMethod::Delete,
HttpMethod::Get => HyperMethod::Get,
HttpMethod::Head => HyperMethod::Head,
HttpMethod::Options => HyperMethod::Options,
HttpMethod::Patch => HyperMethod::Patch,
HttpMethod::Post => HyperMethod::Post,
HttpMethod::Put => HyperMethod::Put,
HttpMethod::Trace => HyperMethod::Trace,
HttpMethod::Custom(x) => HyperMethod::Extension(x.to_owned()),
}
}
}
impl From<HyperMethod> for HttpMethod {
fn from(method: HyperMethod) -> HttpMethod {
match method {
HyperMethod::Connect => HttpMethod::Connect,
HyperMethod::Delete => HttpMethod::Delete,
HyperMethod::Get => HttpMethod::Get,
HyperMethod::Head => HttpMethod::Head,
HyperMethod::Options => HttpMethod::Options,
HyperMethod::Patch => HttpMethod::Patch,
HyperMethod::Post => HttpMethod::Post,
HyperMethod::Put => HttpMethod::Put,
HyperMethod::Trace => HttpMethod::Trace,
HyperMethod::Extension(_) => panic!(d!["unsupported: can't convert a hypermethod(string) into httpmethod(&'static str)"]),
}
}
}