pub enum HeaderName {
Show 20 variants
Host,
ContentType,
ContentLength,
ContentEncoding,
TransferEncoding,
Connection,
Accept,
AcceptEncoding,
Authorization,
UserAgent,
CacheControl,
Location,
Date,
Server,
Cookie,
SetCookie,
Traceparent,
Tracestate,
Baggage,
Custom(Bytes),
}Expand description
An HTTP header name. A name we already know is a unit variant that resolves
to a 'static canonical (lowercase) byte string — zero allocation, integer
compare. An unknown name carries its bytes in HeaderName::Custom.
HeaderName implements IntoHeaderBytes, so headers.insert(HeaderName:: ContentLength, ..) stores Bytes::from_static(b"content-length") with no
copy — the outbound construction win — while HeaderList keeps its Bytes
storage and case-insensitive &str lookups unchanged. HTTP names are
case-insensitive, so from_bytes matches any casing and canonicalizes to
the lowercase static form (what get’s eq_ignore_ascii_case already finds).
Variants§
Host
ContentType
ContentLength
ContentEncoding
TransferEncoding
Connection
Accept
AcceptEncoding
Authorization
UserAgent
CacheControl
Location
Date
Server
Cookie
SetCookie
Traceparent
Tracestate
Baggage
Custom(Bytes)
A non-standard header name, holding its bytes.
Implementations§
Source§impl HeaderName
impl HeaderName
Sourcepub fn from_bytes(bytes: &[u8]) -> Self
pub fn from_bytes(bytes: &[u8]) -> Self
Classify raw bytes case-insensitively. A known name returns a unit
variant (no allocation); an unknown name copies into Custom.
Sourcepub fn from_wire(bytes: Bytes) -> Self
pub fn from_wire(bytes: Bytes) -> Self
Take ownership of wire Bytes: a known name drops the bytes and returns
a unit variant; an unknown name keeps the bytes zero-copy in Custom.
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
The canonical lowercase wire bytes. Known names return a 'static
slice; Custom returns its carried bytes. No allocation.
Trait Implementations§
Source§impl Clone for HeaderName
impl Clone for HeaderName
Source§impl Debug for HeaderName
impl Debug for HeaderName
impl Eq for HeaderName
Source§impl From<&[u8]> for HeaderName
impl From<&[u8]> for HeaderName
Source§impl From<&str> for HeaderName
impl From<&str> for HeaderName
Source§impl From<Bytes> for HeaderName
impl From<Bytes> for HeaderName
Source§impl IntoHeaderBytes for HeaderName
Available on crate feature alloc only.
impl IntoHeaderBytes for HeaderName
alloc only.fn into_header_bytes(self) -> Bytes
Source§impl PartialEq for HeaderName
impl PartialEq for HeaderName
impl StructuralPartialEq for HeaderName
Auto Trait Implementations§
impl !Freeze for HeaderName
impl RefUnwindSafe for HeaderName
impl Send for HeaderName
impl Sync for HeaderName
impl Unpin for HeaderName
impl UnsafeUnpin for HeaderName
impl UnwindSafe for HeaderName
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.