Skip to main content

HeaderSchema

Trait HeaderSchema 

Source
pub trait HeaderSchema: Sized {
    // Required methods
    fn parse(map: &HeaderMap) -> Result<Self, Error>;
    fn dump(&self) -> HeaderMap;
    fn known_names() -> &'static [&'static HeaderName];
}
Expand description

A typed view over a subset of HTTP headers belonging to a particular persona or provider overlay.

Required Methods§

Source

fn parse(map: &HeaderMap) -> Result<Self, Error>

Build the typed struct from a HeaderMap. Returns Error::MissingHeader when a required header is absent and Error::InvalidValue when a value fails domain-specific validation.

Source

fn dump(&self) -> HeaderMap

Render the typed struct back into a HeaderMap. Inverse of [parse]; optional fields that are None are omitted from the output.

The verb dump is deliberately distinct from build: a future build constructor (or build_from_vars) will construct a populated schema from a crate::TemplateVars instance. dump only round-trips an already-populated schema.

Source

fn known_names() -> &'static [&'static HeaderName]

All header names that this schema may emit. Useful for golden-test allowlists and schema documentation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§