From 0ac9e484d892ffee76d8a326b6b3cfca4eb31873 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Mon, 22 Apr 2024 22:39:59 +0800 Subject: [PATCH] feat: Expose streaming as public API Signed-off-by: Xuanwo --- src/async_impl/body.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/async_impl/body.rs b/src/async_impl/body.rs index a70a853b13..06120c1fd1 100644 --- a/src/async_impl/body.rs +++ b/src/async_impl/body.rs @@ -137,8 +137,24 @@ impl Body { } } - // pub? - pub(crate) fn streaming(inner: B) -> Body + /// Wrap a `HttpBody` in a box inside `Body`. + /// + /// # Example + /// + /// ``` + /// # use reqwest::Body; + /// # use futures_util; + /// # fn main() { + /// let content = "hello,world!".to_string(); + /// + /// let body = Body::streaming(content); + /// # } + /// ``` + /// + /// # Optional + /// + /// This requires the `stream` feature to be enabled. + pub fn streaming(inner: B) -> Body where B: HttpBody + Send + Sync + 'static, B::Data: Into,