pub trait HeaderMap {
// Required method
fn get(&self, name: &str) -> Option<&str>;
}Expand description
Case-insensitive, read-only header lookup.
Returns the value of the first header matching name (ASCII
case-insensitively), or None if absent.
§Ambiguity contract
Per spec.md §4.4, a request whose signature header appears multiple times
with different values is ambiguous and must be rejected — but detection of
duplicates belongs to the caller/adapter layer, since this trait exposes
only first-match lookup. Framework adapters are expected to reject
duplicated signature headers before calling crate::verify().
§HashMap caveat
For HashMap the inherent exact-case get shadows this trait method in
method-call position. Pass the map to HeaderMap::get(&map, name) to get
the case-insensitive lookup this crate relies on.
§BTreeMap caveat
For BTreeMap the inherent exact-case get shadows this trait method in
method-call position. Pass the map to HeaderMap::get(&map, name) to get
the case-insensitive lookup this crate relies on.
§Slice caveat
A slice also has an inherent get (indexing by usize) that shadows
this trait method in method-call position. The slices the impls below cover
([(&str, &str)] and [(String, String)]) are usually passed as a &[T]
to crate::verify(), where unsized coercion selects the trait impl —
there is no ambiguity in that position. Method-call syntax on the slice
itself behaves like the maps above: use HeaderMap::get(&slice, name).
§http::HeaderMap support
Behind the http feature this trait is implemented for
http::HeaderMap, so requests from any framework built on the http
crate (axum, tower, hyper) verify without copying headers. Lookup uses
that type’s own first-value-wins, case-insensitive semantics; a value
that is not visible ASCII (which http permits but this crate cannot
treat as a signature) is reported as absent, failing closed downstream
as a missing header.
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl HeaderMap for HeaderMap
Bridge for actix-web 4’s internal http 0.2 header map: enables passing
req.headers() straight into crate::verify().
impl HeaderMap for HeaderMap
Bridge for actix-web 4’s internal http 0.2 header map: enables passing
req.headers() straight into crate::verify().
Lookup mirrors the http 1.x impl in src/core/headers.rs: typed-name
lookups are ASCII case-insensitive and first-value-wins; a value that is
not visible ASCII (which http permits but this crate cannot treat as a
signature) is reported as absent, failing closed downstream. Duplicate
detection stays with the adapter — see the trait’s ambiguity contract.
Source§impl HeaderMap for [(&str, &str)]
Borrowed slice of str tuples — covers subsections of a header table
(&vec[..], &array[1..], a function parameter that hands you &[..])
without an owning allocation alongside the array impl.
impl HeaderMap for [(&str, &str)]
Borrowed slice of str tuples — covers subsections of a header table
(&vec[..], &array[1..], a function parameter that hands you &[..])
without an owning allocation alongside the array impl.
Source§impl HeaderMap for [(String, String)]
Borrowed slice of owned strings, the unsized counterpart of the
[(String, String); N] array impl.
impl HeaderMap for [(String, String)]
Borrowed slice of owned strings, the unsized counterpart of the
[(String, String); N] array impl.