1 //! HTTP specific body utilities.
2 
3 use http_body::Body;
4 
5 /// A type erased HTTP body used for tonic services.
6 pub type BoxBody = http_body::combinators::UnsyncBoxBody<bytes::Bytes, crate::Status>;
7 
8 /// Convert a [`http_body::Body`] into a [`BoxBody`].
boxed<B>(body: B) -> BoxBody where B: http_body::Body<Data = bytes::Bytes> + Send + 'static, B::Error: Into<crate::Error>,9 pub(crate) fn boxed<B>(body: B) -> BoxBody
10 where
11     B: http_body::Body<Data = bytes::Bytes> + Send + 'static,
12     B::Error: Into<crate::Error>,
13 {
14     body.map_err(crate::Status::map_error).boxed_unsync()
15 }
16 
17 /// Create an empty `BoxBody`
empty_body() -> BoxBody18 pub fn empty_body() -> BoxBody {
19     http_body::Empty::new()
20         .map_err(|err| match err {})
21         .boxed_unsync()
22 }
23