From 505e4c4c59bc3ddacfc2ee2cc94992a902f1ef63 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 dee852c..2ddc2bc 100644 --- a/http-body-util/src/lib.rs +++ b/http-body-util/src/lib.rs @@ -72,6 +72,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.