From 1932d0c89f81c4c3bc0b6904fde9a76f6dda4ddc Mon Sep 17 00:00:00 2001 From: Xiaobo Liu Date: Wed, 20 Sep 2023 21:23:42 +0800 Subject: [PATCH] Response support parse_with_uninit_headers Signed-off-by: Xiaobo Liu --- src/lib.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 0e3cb6c..e961158 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -643,6 +643,18 @@ impl<'h, 'b> Response<'h, 'b> { self.parse_with_config(buf, &ParserConfig::default()) } + /// Try to parse a buffer of bytes into the Response, + /// except use an uninitialized slice of `Header`s. + /// + /// For more information, see `parse` + pub fn parse_with_uninit_headers( + &mut self, + buf: &'b [u8], + headers: &'h mut [MaybeUninit>], + ) -> Result { + self.parse_with_config_and_uninit_headers(buf, &Default::default(), headers) + } + fn parse_with_config(&mut self, buf: &'b [u8], config: &ParserConfig) -> Result { let headers = core::mem::replace(&mut self.headers, &mut []);