From cd52d9dcb198fc8129058abf8ac8189254163222 Mon Sep 17 00:00:00 2001 From: Sean Lynch <42618346+swlynch99@users.noreply.github.com> Date: Thu, 14 Mar 2024 11:27:56 -0700 Subject: [PATCH] feat: Add `Collected::take_trailers` --- http-body-util/src/collected.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/http-body-util/src/collected.rs b/http-body-util/src/collected.rs index 31a02a4..5325f70 100644 --- a/http-body-util/src/collected.rs +++ b/http-body-util/src/collected.rs @@ -28,6 +28,13 @@ impl Collected { self.trailers.as_ref() } + /// If there is a trailers frame buffered, remove and return it. + /// + /// Returns `None` if the body contained no trailers. + pub fn take_trailers(&mut self) -> Option { + self.trailers.take() + } + /// Aggregate this buffered into a [`Buf`]. pub fn aggregate(self) -> impl Buf { self.bufs