Struct tauri::http::header::HeaderName
x3A;:header::HeaderName,
pub struct HeaderName { /* fields omitted */ }
Expand description
Represents an HTTP header field name
Header field names identify the header. Header sets may include multiple headers with the same name. The HTTP specification defines a number of standard headers, but HTTP messages may include non-standard header names as well as long as they adhere to the specification.
HeaderName
is used as the HeaderMap
key. Constants are available for all standard header names in the header
module.
#
RepresentationHeaderName
represents standard header names using an enum
, as such they will not require an allocation for storage. All custom header names are lower cased upon conversion to a HeaderName
value. This avoids the overhead of dynamically doing lower case conversion during the hash code computation and the comparison operation.
#
ImplementationsHeaderName[src]#
implfrom_bytes(src: &[u8]) -> Result<HeaderName, InvalidHeaderName>[src]#
pub fnConverts a slice of bytes to an HTTP header name.
This function normalizes the input.
from_lowercase(src: &[u8]) -> Result<HeaderName, InvalidHeaderName>[src]#
pub fnConverts a slice of bytes to an HTTP header name.
This function expects the input to only contain lowercase characters. This is useful when decoding HTTP/2.0 or HTTP/3.0 headers. Both require that all headers be represented in lower case.
#
Examples// Parsing a lower case header
let hdr = HeaderName::from_lowercase(b"content-length").unwrap();
assert_eq!(CONTENT_LENGTH, hdr);
// Parsing a header that contains uppercase characters
assert!(HeaderName::from_lowercase(b"Content-Length").is_err());
from_static(src: &'static str) -> HeaderName[src]#
pub fnConverts a static string to a HTTP header name.
This function panics when the static string is a invalid header.
This function requires the static string to only contain lowercase characters, numerals and symbols, as per the HTTP/2.0 specification and header names internal representation within this library.
#
Examples// Parsing a standard header
let hdr = HeaderName::from_static("content-length");
assert_eq!(CONTENT_LENGTH, hdr);
// Parsing a custom header
let CUSTOM_HEADER: &'static str = "custom-header";
let a = HeaderName::from_lowercase(b"custom-header").unwrap();
let b = HeaderName::from_static(CUSTOM_HEADER);
assert_eq!(a, b);
ⓘ
// Parsing a header that contains invalid symbols(s):
HeaderName::from_static("content{}{}length"); // This line panics!
// Parsing a header that contains invalid uppercase characters.
let a = HeaderName::from_static("foobar");
let b = HeaderName::from_static("FOOBAR"); // This line panics!
as_str(&self) -> &str[src]#
pub fnReturns a str
representation of the header.
The returned string will always be lower case.
#
Trait ImplementationsAsRef<[u8]> for HeaderName[src]#
implas_ref(&self) -> &[u8][src]#
pub fnPerforms the conversion.
AsRef<str> for HeaderName[src]#
implas_ref(&self) -> &str[src]#
pub fnPerforms the conversion.
Borrow<str> for HeaderName[src]#
implborrow(&self) -> &str[src]#
pub fnImmutably borrows from an owned value. Read more
Clone for HeaderName[src]#
implclone(&self) -> HeaderName[src]#
pub fnReturns a copy of the value. Read more
clone_from(&mut self, source: &Self)1.0.0[src]#
fnPerforms copy-assignment from source
. Read more
Debug for HeaderName[src]#
implfmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>[src]#
pub fnFormats the value using the given formatter. Read more
Display for HeaderName[src]#
implfmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>[src]#
pub fnFormats the value using the given formatter. Read more
From<<'a HeaderName> for HeaderName[src]#
impl<'a>from(src: &'a HeaderName) -> HeaderName[src]#
pub fnPerforms the conversion.
From<HeaderName> for HeaderValue[src]#
implfrom(h: HeaderName) -> HeaderValue[src]#
pub fnPerforms the conversion.
FromStr for HeaderName[src]#
implErr = InvalidHeaderName#
typeThe associated error which can be returned from parsing.
from_str(s: &str) -> Result<HeaderName, InvalidHeaderName>[src]#
pub fnParses a string s
to return a value of this type. Read more
Hash for HeaderName[src]#
implhash<__H>(&self, state: &mut__H) where __H: Hasher,[src]#
pub fnFeeds this value into the given Hasher
. Read more
hash_slice<H>(data: &[Self], state: &mutH) where H: Hasher,1.3.0[src]#
fnFeeds a slice of this type into the given Hasher
. Read more
PartialEq<<'a HeaderName> for HeaderName[src]#
impl<'a>eq(&self, other: &&'a HeaderName) -> bool[src]#
pub fnThis method tests for self
and other
values to be equal, and is used by ==
. Read more
ne(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests for !=
.
PartialEq<<'a str> for HeaderName[src]#
impl<'a>eq(&self, other: &&'a str) -> bool[src]#
pub fnPerforms a case-insensitive comparison of the string against the header name
ne(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests for !=
.
PartialEq<HeaderName> for HeaderName[src]#
impleq(&self, other: &HeaderName) -> bool[src]#
pub fnThis method tests for self
and other
values to be equal, and is used by ==
. Read more
ne(&self, other: &HeaderName) -> bool[src]#
pub fnThis method tests for !=
.
PartialEq<HeaderName> for &'a HeaderName[src]#
impl<'a>eq(&self, other: &HeaderName) -> bool[src]#
pub fnThis method tests for self
and other
values to be equal, and is used by ==
. Read more
ne(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests for !=
.
PartialEq<str> for HeaderName[src]#
impleq(&self, other: &str) -> bool[src]#
pub fnPerforms a case-insensitive comparison of the string against the header name
#
Examplesuse http::header::CONTENT_LENGTH;
assert_eq!(CONTENT_LENGTH, "content-length");
assert_eq!(CONTENT_LENGTH, "Content-Length");
assert_ne!(CONTENT_LENGTH, "content length");
ne(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests for !=
.
TryFrom<&'a [u8]> for HeaderName[src]#
impl<'a>Error = InvalidHeaderName#
typeThe type returned in the event of a conversion error.
try_from( s: &'a [u8] ) -> Result<HeaderName, <HeaderName as TryFrom<&'a [u8]>>::Error>[src]#
pub fnPerforms the conversion.
TryFrom<<'a String> for HeaderName[src]#
impl<'a>Error = InvalidHeaderName#
typeThe type returned in the event of a conversion error.
try_from( s: &'a String ) -> Result<HeaderName, <HeaderName as TryFrom<<'a String>>::Error>[src]#
pub fnPerforms the conversion.
TryFrom<<'a str> for HeaderName[src]#
impl<'a>Error = InvalidHeaderName#
typeThe type returned in the event of a conversion error.
try_from( s: &'a str ) -> Result<HeaderName, <HeaderName as TryFrom<<'a str>>::Error>[src]#
pub fnPerforms the conversion.
AsHeaderName for &'a HeaderName#
impl<'a>AsHeaderName for HeaderName#
implEq for HeaderName#
implIntoHeaderName for &'a HeaderName#
impl<'a>IntoHeaderName for HeaderName#
implStructuralEq for HeaderName#
implStructuralPartialEq for HeaderName#
impl#
Auto Trait ImplementationsRefUnwindSafe for HeaderName#
implSend for HeaderName#
implSync for HeaderName#
implUnpin for HeaderName#
implUnwindSafe for HeaderName#
impl#
Blanket ImplementationsAny for T where T: 'static + ?Sized,[src]#
impl<T>type_id(&self) -> TypeId[src]#
pub fnGets the TypeId
of self
. Read more
Borrow<T> for T where T: ?Sized,[src]#
impl<T>borrow(&self) -> &T[src]#
pub fnImmutably borrows from an owned value. Read more
BorrowMut<T> for T where T: ?Sized,[src]#
impl<T>borrow_mut(&mut self) -> &mutT[src]#
pub fnMutably borrows from an owned value. Read more
From<T> for T[src]#
impl<T>from(t: T) -> T[src]#
pub fnPerforms the conversion.
Into<U> for T where U: From<T>,[src]#
impl<T, U>into(self) -> U[src]#
pub fnPerforms the conversion.
ToOwned for T where T: Clone,[src]#
impl<T>Owned = T#
typeThe resulting type after obtaining ownership.
to_owned(&self) -> T[src]#
pub fnCreates owned data from borrowed data, usually by cloning. Read more
clone_into(&self, target: &mutT)[src]#
pub fn🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
ToString for T where T: Display + ?Sized,[src]#
impl<T>to_string(&self) -> String[src]#
pub default fnConverts the given value to a String
. Read more
TryFrom<U> for T where U: Into<T>,[src]#
impl<T, U>Error = Infallible#
typeThe type returned in the event of a conversion error.
try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]#
pub fnPerforms the conversion.
TryInto<U> for T where U: TryFrom<T>,[src]#
impl<T, U>Error = <U as TryFrom<T>>::Error#
typeThe type returned in the event of a conversion error.
try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]#
pub fnPerforms the conversion.