From e57bf12768ea60019d4b490e25d7593000ef28ac Mon Sep 17 00:00:00 2001 From: vvvviiv Date: Sun, 23 Jun 2024 19:48:51 +0800 Subject: [PATCH] feat(util): add `BodyExt::limited` --- http-body-util/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/http-body-util/src/lib.rs b/http-body-util/src/lib.rs index ae2c369..5b68cf1 100644 --- a/http-body-util/src/lib.rs +++ b/http-body-util/src/lib.rs @@ -100,6 +100,14 @@ pub trait BodyExt: http_body::Body { UnsyncBoxBody::new(self) } + /// Turn this body into a [`Limited`] body with the given limit. + fn limited(self, limit: usize) -> Limited + where + Self: Sized, + { + Limited::new(self, limit) + } + /// Turn this body into [`Collected`] body which will collect all the DATA frames /// and trailers. fn collect(self) -> combinators::Collect