1use bytes::Bytes;
2use http_body_util::Full;
3
4pub struct Form<T> {
5 pub(crate) value: T,
6}
7
8impl<T> Form<T> {
9 pub fn new(value: T) -> Self {
10 Form { value }
11 }
12
13 pub fn value(&self) -> &T {
14 &self.value
15 }
16
17 pub fn take(self) -> T {
18 self.value
19 }
20}
21
22pub struct Html {
23 pub(crate) body: Full<Bytes>,
24}
25
26impl Html {
27 pub fn new(body: impl Into<Bytes>) -> Self {
28 Html {
29 body: Full::new(body.into()),
30 }
31 }
32}
33
34pub struct Json<T> {
35 pub(crate) value: T,
36}
37
38impl<T> Json<T> {
39 pub fn new(value: T) -> Self {
40 Json { value }
41 }
42
43 pub fn value(&self) -> &T {
44 &self.value
45 }
46
47 pub fn take(self) -> T {
48 self.value
49 }
50}
51
52pub struct StreamBody<S> {
53 pub(crate) s: S,
54 pub(crate) content_type: mime::Mime,
55}
56
57impl<S, B, E> StreamBody<S>
58where
59 S: futures::Stream<Item = Result<B, E>> + Send + Sync + 'static,
60 B: Into<Bytes> + 'static,
61 E: Into<crate::Error> + Send + Sync + 'static,
62{
63 pub fn new(s: S, content_type: mime::Mime) -> Self {
64 StreamBody { s, content_type }
65 }
66}
67
68pub struct BytesBody {
69 pub(crate) body: Bytes,
70 pub(crate) content_type: mime::Mime,
71}
72
73impl BytesBody {
74 pub fn new(body: impl Into<Bytes>, content_type: mime::Mime) -> Self {
75 BytesBody {
76 body: body.into(),
77 content_type,
78 }
79 }
80
81 pub fn value(&self) -> &Bytes {
82 &self.body
83 }
84
85 pub fn take(self) -> Bytes {
86 self.body
87 }
88}