Skip to main content

DocumentedHeader

Trait DocumentedHeader 

Source
pub trait DocumentedHeader {
    // Required method
    fn name() -> &'static str;

    // Provided methods
    fn description() -> &'static str { ... }
    fn example() -> Option<&'static str> { ... }
}
Expand description

Type-level descriptor for one HTTP header.

Implementations are typically zero-sized marker structs:

use doxa::DocumentedHeader;

pub struct BearerAuthorization;
impl DocumentedHeader for BearerAuthorization {
    fn name() -> &'static str { "Authorization" }
    fn description() -> &'static str {
        "Bearer JWT issued by the configured identity provider."
    }
    fn example() -> Option<&'static str> {
        Some("Bearer eyJhbGc...")
    }
}

All accessors are runtime functions (not associated consts) so a future blanket impl can adapt foreign traits whose names are only available through methods — e.g. impl<H: headers::Header> DocumentedHeader for H behind an opt-in cargo feature.

Required Methods§

Source

fn name() -> &'static str

Wire name of the header. HTTP header names are case-insensitive, but OpenAPI viewers (Scalar, Swagger UI) render the name verbatim — use the title-cased form your consumers expect to see (Authorization, not authorization).

Provided Methods§

Source

fn description() -> &'static str

Human description rendered in the docs UI. Empty string omits the description from the spec.

Source

fn example() -> Option<&'static str>

Optional example value rendered alongside the parameter.

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.

Implementors§