pub trait HeadParser<'de>: Sized {
// Required method
fn parse_head_section(head: &'de str) -> Result<Self, Error>;
// Provided method
fn parse_headers(
head_and_body: &'de [u8],
) -> Result<(Self, &'de [u8]), Error> { ... }
}Expand description
The HeadParser trait provides a way to parse HTTP headers and potentially
returns the parsed headers and the remaining body of an HTTP message.
This trait is intended to be automatically implemented by the noggin::Noggin
procedural macro for suitable structs. As such, users shouldn’t typically
need to implement it manually.
Required Methods§
Sourcefn parse_head_section(head: &'de str) -> Result<Self, Error>
fn parse_head_section(head: &'de str) -> Result<Self, Error>
Provided Methods§
Sourcefn parse_headers(head_and_body: &'de [u8]) -> Result<(Self, &'de [u8]), Error>
fn parse_headers(head_and_body: &'de [u8]) -> Result<(Self, &'de [u8]), Error>
Parse the HTTP headers and returns both the parsed headers and the remaining body from a byte slice containing both head and body sections of an HTTP message.
This function first locates the boundary between the head and body sections
(denoted by the sequence \r\n\r\n), then validates the ASCII nature of the
head, and finally calls the parse_head_section function to parse the headers.
§Parameters
head_and_body: A byte slice containing both the head and body sections of an HTTP message.
§Returns
Result<(Self, &'de [u8]), Error>: Returns a tuple containing the parsed headers and the remaining body if successful, or an error if parsing fails.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.