Struct tauri::http::header::HeaderValue
x3A;:header::HeaderValue,
pub struct HeaderValue { /* fields omitted */ }
Expand description
Represents an HTTP header field value.
In practice, HTTP header field values are usually valid ASCII. However, the HTTP spec allows for a header value to contain opaque bytes as well. In this case, the header field value is not able to be represented as a string.
To handle this, the HeaderValue
is useable as a type and can be compared with strings and implements Debug
. A to_str
fn is provided that returns an Err
if the header value contains non visible ascii characters.
#
ImplementationsHeaderValue[src]#
implfrom_static(src: &'static str) -> HeaderValue[src]#
pub fnConvert a static string to a HeaderValue
.
This function will not perform any copying, however the string is checked to ensure that no invalid characters are present. Only visible ASCII characters (32-127) are permitted.
#
PanicsThis function panics if the argument contains invalid header value characters.
#
Exampleslet val = HeaderValue::from_static("hello");
assert_eq!(val, "hello");
from_str(src: &str) -> Result<HeaderValue, InvalidHeaderValue>[src]#
pub fnAttempt to convert a string to a HeaderValue
.
If the argument contains invalid header value characters, an error is returned. Only visible ASCII characters (32-127) are permitted. Use from_bytes
to create a HeaderValue
that includes opaque octets (128-255).
This function is intended to be replaced in the future by a TryFrom
implementation once the trait is stabilized in std.
#
Exampleslet val = HeaderValue::from_str("hello").unwrap();
assert_eq!(val, "hello");
An invalid value
let val = HeaderValue::from_str("\n");
assert!(val.is_err());
from_name(name: HeaderName) -> HeaderValue[src]#
pub fnConverts a HeaderName into a HeaderValue
Since every valid HeaderName is a valid HeaderValue this is done infallibly.
#
Exampleslet val = HeaderValue::from_name(ACCEPT);
assert_eq!(val, HeaderValue::from_bytes(b"accept").unwrap());
from_bytes(src: &[u8]) -> Result<HeaderValue, InvalidHeaderValue>[src]#
pub fnAttempt to convert a byte slice to a HeaderValue
.
If the argument contains invalid header value bytes, an error is returned. Only byte values between 32 and 255 (inclusive) are permitted, excluding byte 127 (DEL).
This function is intended to be replaced in the future by a TryFrom
implementation once the trait is stabilized in std.
#
Exampleslet val = HeaderValue::from_bytes(b"hello\xfa").unwrap();
assert_eq!(val, &b"hello\xfa"[..]);
An invalid value
let val = HeaderValue::from_bytes(b"\n");
assert!(val.is_err());
from_maybe_shared<T>(src: T) -> Result<HeaderValue, InvalidHeaderValue> where T: AsRef<[u8]> + 'static,[src]#
pub fnAttempt to convert a Bytes
buffer to a HeaderValue
.
This will try to prevent a copy if the type passed is the type used internally, and will copy the data if it is not.
from_maybe_shared_unchecked<T>(src: T) -> HeaderValue where T: AsRef<[u8]> + 'static,[src]#
pub unsafe fnConvert a Bytes
directly into a HeaderValue
without validating.
This function does NOT validate that illegal bytes are not contained within the buffer.
to_str(&self) -> Result<&str, ToStrError>[src]#
pub fnYields a &str
slice if the HeaderValue
only contains visible ASCII chars.
This function will perform a scan of the header value, checking all the characters.
#
Exampleslet val = HeaderValue::from_static("hello");
assert_eq!(val.to_str().unwrap(), "hello");
len(&self) -> usize[src]#
pub fnReturns the length of self
.
This length is in bytes.
#
Exampleslet val = HeaderValue::from_static("hello");
assert_eq!(val.len(), 5);
is_empty(&self) -> bool[src]#
pub fnReturns true if the HeaderValue
has a length of zero bytes.
#
Exampleslet val = HeaderValue::from_static("");
assert!(val.is_empty());
let val = HeaderValue::from_static("hello");
assert!(!val.is_empty());
as_bytes(&self) -> &[u8][src]#
pub fnConverts a HeaderValue
to a byte slice.
#
Exampleslet val = HeaderValue::from_static("hello");
assert_eq!(val.as_bytes(), b"hello");
set_sensitive(&mut self, val: bool)[src]#
pub fnMark that the header value represents sensitive information.
#
Exampleslet mut val = HeaderValue::from_static("my secret");
val.set_sensitive(true);
assert!(val.is_sensitive());
val.set_sensitive(false);
assert!(!val.is_sensitive());
is_sensitive(&self) -> bool[src]#
pub fnReturns true
if the value represents sensitive data.
Sensitive data could represent passwords or other data that should not be stored on disk or in memory. By marking header values as sensitive, components using this crate can be instructed to treat them with special care for security reasons. For example, caches can avoid storing sensitive values, and HPACK encoders used by HTTP/2.0 implementations can choose not to compress them.
Additionally, sensitive values will be masked by the Debug
implementation of HeaderValue
.
Note that sensitivity is not factored into equality or ordering.
#
Exampleslet mut val = HeaderValue::from_static("my secret");
val.set_sensitive(true);
assert!(val.is_sensitive());
val.set_sensitive(false);
assert!(!val.is_sensitive());
#
Trait ImplementationsAsRef<[u8]> for HeaderValue[src]#
implas_ref(&self) -> &[u8][src]#
pub fnPerforms the conversion.
Clone for HeaderValue[src]#
implclone(&self) -> HeaderValue[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 HeaderValue[src]#
implfmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]#
pub fnFormats the value using the given formatter. Read more
From<<'a HeaderValue> for HeaderValue[src]#
impl<'a>from(t: &'a HeaderValue) -> HeaderValue[src]#
pub fnPerforms the conversion.
From<HeaderName> for HeaderValue[src]#
implfrom(h: HeaderName) -> HeaderValue[src]#
pub fnPerforms the conversion.
From<i16> for HeaderValue[src]#
implfrom(num: i16) -> HeaderValue[src]#
pub fnPerforms the conversion.
From<i32> for HeaderValue[src]#
implfrom(num: i32) -> HeaderValue[src]#
pub fnPerforms the conversion.
From<i64> for HeaderValue[src]#
implfrom(num: i64) -> HeaderValue[src]#
pub fnPerforms the conversion.
From<isize> for HeaderValue[src]#
implfrom(num: isize) -> HeaderValue[src]#
pub fnPerforms the conversion.
From<u16> for HeaderValue[src]#
implfrom(num: u16) -> HeaderValue[src]#
pub fnPerforms the conversion.
From<u32> for HeaderValue[src]#
implfrom(num: u32) -> HeaderValue[src]#
pub fnPerforms the conversion.
From<u64> for HeaderValue[src]#
implfrom(num: u64) -> HeaderValue[src]#
pub fnPerforms the conversion.
From<usize> for HeaderValue[src]#
implfrom(num: usize) -> HeaderValue[src]#
pub fnPerforms the conversion.
FromStr for HeaderValue[src]#
implErr = InvalidHeaderValue#
typeThe associated error which can be returned from parsing.
from_str(s: &str) -> Result<HeaderValue, <HeaderValue as FromStr>::Err>[src]#
pub fnParses a string s
to return a value of this type. Read more
Hash for HeaderValue[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
Ord for HeaderValue[src]#
implcmp(&self, other: &HeaderValue) -> Ordering[src]#
pub fnThis method returns an Ordering
between self
and other
. Read more
max(self, other: Self) -> Self1.21.0[src]#
#[must_use]fnCompares and returns the maximum of two values. Read more
min(self, other: Self) -> Self1.21.0[src]#
#[must_use]fnCompares and returns the minimum of two values. Read more
clamp(self, min: Self, max: Self) -> Self1.50.0[src]#
#[must_use]fnRestrict a value to a certain interval. Read more
PartialEq<&'aT> for HeaderValue where T: ?Sized, HeaderValue: PartialEq<T>,[src]#
impl<'a, T>eq(&self, other: &&'aT) -> 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<[u8]> for HeaderValue[src]#
impleq(&self, other: &[u8]) -> 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<HeaderValue> for HeaderValue[src]#
impleq(&self, other: &HeaderValue) -> 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<HeaderValue> for &'a HeaderValue[src]#
impl<'a>eq(&self, other: &HeaderValue) -> 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<String> for HeaderValue[src]#
impleq(&self, other: &String) -> 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 HeaderValue[src]#
impleq(&self, other: &str) -> 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 !=
.
PartialOrd<&'aT> for HeaderValue where T: ?Sized, HeaderValue: PartialOrd<T>,[src]#
impl<'a, T>partial_cmp(&self, other: &&'aT) -> Option<Ordering>[src]#
pub fnThis method returns an ordering between self
and other
values if one exists. Read more
lt(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests less than (for self
and other
) and is used by the <
operator. Read more
le(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
gt(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests greater than (for self
and other
) and is used by the >
operator. Read more
ge(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
PartialOrd<[u8]> for HeaderValue[src]#
implpartial_cmp(&self, other: &[u8]) -> Option<Ordering>[src]#
pub fnThis method returns an ordering between self
and other
values if one exists. Read more
lt(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests less than (for self
and other
) and is used by the <
operator. Read more
le(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
gt(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests greater than (for self
and other
) and is used by the >
operator. Read more
ge(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
PartialOrd<HeaderValue> for &'a HeaderValue[src]#
impl<'a>partial_cmp(&self, other: &HeaderValue) -> Option<Ordering>[src]#
pub fnThis method returns an ordering between self
and other
values if one exists. Read more
lt(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests less than (for self
and other
) and is used by the <
operator. Read more
le(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
gt(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests greater than (for self
and other
) and is used by the >
operator. Read more
ge(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
PartialOrd<HeaderValue> for HeaderValue[src]#
implpartial_cmp(&self, other: &HeaderValue) -> Option<Ordering>[src]#
pub fnThis method returns an ordering between self
and other
values if one exists. Read more
lt(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests less than (for self
and other
) and is used by the <
operator. Read more
le(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
gt(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests greater than (for self
and other
) and is used by the >
operator. Read more
ge(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
PartialOrd<String> for HeaderValue[src]#
implpartial_cmp(&self, other: &String) -> Option<Ordering>[src]#
pub fnThis method returns an ordering between self
and other
values if one exists. Read more
lt(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests less than (for self
and other
) and is used by the <
operator. Read more
le(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
gt(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests greater than (for self
and other
) and is used by the >
operator. Read more
ge(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
PartialOrd<str> for HeaderValue[src]#
implpartial_cmp(&self, other: &str) -> Option<Ordering>[src]#
pub fnThis method returns an ordering between self
and other
values if one exists. Read more
lt(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests less than (for self
and other
) and is used by the <
operator. Read more
le(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
gt(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests greater than (for self
and other
) and is used by the >
operator. Read more
ge(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
TryFrom<&'a [u8]> for HeaderValue[src]#
impl<'a>Error = InvalidHeaderValue#
typeThe type returned in the event of a conversion error.
try_from( t: &'a [u8] ) -> Result<HeaderValue, <HeaderValue as TryFrom<&'a [u8]>>::Error>[src]#
pub fnPerforms the conversion.
TryFrom<<'a String> for HeaderValue[src]#
impl<'a>Error = InvalidHeaderValue#
typeThe type returned in the event of a conversion error.
try_from( s: &'a String ) -> Result<HeaderValue, <HeaderValue as TryFrom<<'a String>>::Error>[src]#
pub fnPerforms the conversion.
TryFrom<<'a str> for HeaderValue[src]#
impl<'a>Error = InvalidHeaderValue#
typeThe type returned in the event of a conversion error.
try_from( t: &'a str ) -> Result<HeaderValue, <HeaderValue as TryFrom<<'a str>>::Error>[src]#
pub fnPerforms the conversion.
TryFrom<String> for HeaderValue[src]#
implError = InvalidHeaderValue#
typeThe type returned in the event of a conversion error.
try_from( t: String ) -> Result<HeaderValue, <HeaderValue as TryFrom<String>>::Error>[src]#
pub fnPerforms the conversion.
TryFrom<Vec<u8, Global>> for HeaderValue[src]#
implError = InvalidHeaderValue#
typeThe type returned in the event of a conversion error.
try_from( vec: Vec<u8, Global> ) -> Result<HeaderValue, <HeaderValue as TryFrom<Vec<u8, Global>>>::Error>[src]#
pub fnPerforms the conversion.
Eq for HeaderValue#
impl#
Auto Trait ImplementationsRefUnwindSafe for HeaderValue#
implSend for HeaderValue#
implSync for HeaderValue#
implUnpin for HeaderValue#
implUnwindSafe for HeaderValue#
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
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.