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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
use bytes::Bytes;
use hyper::Body;
#[derive(Debug, Default)]
pub struct HttpContent {
underlying: Body,
}
impl HttpContent {
pub fn none() -> HttpContent {
HttpContent { underlying: Body::default() }
}
}
impl Into<Body> for HttpContent {
fn into(self) -> Body {
self.underlying
}
}
impl From<Bytes> for HttpContent {
#[inline]
fn from(bytes: Bytes) -> HttpContent {
HttpContent { underlying: bytes.into() }
}
}
impl From<Vec<u8>> for HttpContent {
#[inline]
fn from(vec: Vec<u8>) -> HttpContent {
HttpContent { underlying: vec.into() }
}
}
impl From<&'static [u8]> for HttpContent {
#[inline]
fn from(slice: &'static [u8]) -> HttpContent {
HttpContent { underlying: slice.into() }
}
}
impl From<String> for HttpContent {
#[inline]
fn from(string: String) -> HttpContent {
HttpContent { underlying: string.into() }
}
}
impl From<&'static str> for HttpContent {
#[inline]
fn from(slice: &'static str) -> HttpContent {
HttpContent { underlying: slice.into() }
}
}
impl From<Option<Body>> for HttpContent {
#[inline]
fn from(body: Option<Body>) -> HttpContent {
HttpContent { underlying: body.into() }
}
}
impl<T> From<Option<T>> for HttpContent where T: Into<HttpContent> {
#[inline]
fn from(body: Option<T>) -> HttpContent {
match body {
Some(x) => x.into(),
None => HttpContent::none(),
}
}
}