pub fn intern_header_name(name: &str) -> CowHeaderNameExpand description
Intern a header name, returning a static reference for known headers.
This is the key optimization: common headers like “Content-Type” or
“Authorization” return Cow::Borrowed(&'static str) instead of
allocating a new String.
§Performance
- Known headers: O(1) lookup, zero allocation
- Unknown headers: O(1) to create owned Cow, one allocation
§Example
use sentinel_agent_protocol::headers::intern_header_name;
use std::borrow::Cow;
// Known header - no allocation
let ct = intern_header_name("content-type");
assert!(matches!(ct, Cow::Borrowed(_)));
// Unknown header - allocates once
let custom = intern_header_name("x-custom-header");
assert!(matches!(custom, Cow::Owned(_)));