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
use std::ops::{Deref, DerefMut};

/// A wrapper type around the internal [hyper::Body]
pub struct Body(pub(crate) hyper::Body);

impl Body {
    pub fn new(inner: hyper::Body) -> Self {
        Self(inner)
    }

    /// Consumes the body returning the inner hyper object.
    pub fn into_inner(self) -> hyper::Body {
        self.0
    }
}

impl<T> From<T> for Body
where
    T: Into<hyper::Body>,
{
    fn from(value: T) -> Self {
        Self(value.into())
    }
}

impl Deref for Body {
    type Target = hyper::Body;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for Body {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}