[−][src]Struct tower_grpc::metadata::MetadataKey
Represents a custom metadata field name.
MetadataKey
is used as the [MetadataMap
] key.
Methods
impl<VE: ValueEncoding> MetadataKey<VE>
[src]
pub fn from_bytes(src: &[u8]) -> Result<Self, InvalidMetadataKey>
[src]
Converts a slice of bytes to a MetadataKey
.
This function normalizes the input.
pub fn from_static(src: &'static str) -> Self
[src]
Converts a static string to a MetadataKey
.
This function panics when the static string is a invalid metadata key.
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 metadata key let CUSTOM_KEY: &'static str = "custom-key"; let a = AsciiMetadataKey::from_bytes(b"custom-key").unwrap(); let b = AsciiMetadataKey::from_static(CUSTOM_KEY); assert_eq!(a, b);
// Parsing a metadata key that contains invalid symbols(s): AsciiMetadataKey::from_static("content{}{}length"); // This line panics!
// Parsing a metadata key that contains invalid uppercase characters. let a = AsciiMetadataKey::from_static("foobar"); let b = AsciiMetadataKey::from_static("FOOBAR"); // This line panics!
// Parsing a -bin metadata key as an Ascii key. let b = AsciiMetadataKey::from_static("hello-bin"); // This line panics!
// Parsing a non-bin metadata key as an Binary key. let b = BinaryMetadataKey::from_static("hello"); // This line panics!
pub fn as_str(&self) -> &str
[src]
Returns a str
representation of the metadata key.
The returned string will always be lower case.
Trait Implementations
impl<'a, VE: ValueEncoding> From<&'a MetadataKey<VE>> for MetadataKey<VE>
[src]
fn from(src: &'a MetadataKey<VE>) -> MetadataKey<VE>
[src]
impl<VE: ValueEncoding> From<MetadataKey<VE>> for Bytes
[src]
fn from(name: MetadataKey<VE>) -> Bytes
[src]
impl<KeyVE: ValueEncoding> From<MetadataKey<KeyVE>> for MetadataValue<Ascii>
[src]
fn from(h: MetadataKey<KeyVE>) -> MetadataValue<Ascii>
[src]
impl<VE: ValueEncoding> AsRef<str> for MetadataKey<VE>
[src]
impl<VE: ValueEncoding> AsRef<[u8]> for MetadataKey<VE>
[src]
impl<VE: Clone + ValueEncoding> Clone for MetadataKey<VE>
[src]
fn clone(&self) -> MetadataKey<VE>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<VE: PartialEq + ValueEncoding> PartialEq<MetadataKey<VE>> for MetadataKey<VE>
[src]
fn eq(&self, other: &MetadataKey<VE>) -> bool
[src]
fn ne(&self, other: &MetadataKey<VE>) -> bool
[src]
impl<'a, VE: ValueEncoding> PartialEq<&'a MetadataKey<VE>> for MetadataKey<VE>
[src]
fn eq(&self, other: &&'a MetadataKey<VE>) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<'a, VE: ValueEncoding> PartialEq<MetadataKey<VE>> for &'a MetadataKey<VE>
[src]
fn eq(&self, other: &MetadataKey<VE>) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<VE: ValueEncoding> PartialEq<str> for MetadataKey<VE>
[src]
fn eq(&self, other: &str) -> bool
[src]
Performs a case-insensitive comparison of the string against the header name
Examples
let content_length = AsciiMetadataKey::from_static("content-length"); assert_eq!(content_length, "content-length"); assert_eq!(content_length, "Content-Length"); assert_ne!(content_length, "content length");
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<VE: ValueEncoding> PartialEq<MetadataKey<VE>> for str
[src]
fn eq(&self, other: &MetadataKey<VE>) -> bool
[src]
Performs a case-insensitive comparison of the string against the header name
Examples
let content_length = AsciiMetadataKey::from_static("content-length"); assert_eq!(content_length, "content-length"); assert_eq!(content_length, "Content-Length"); assert_ne!(content_length, "content length");
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<'a, VE: ValueEncoding> PartialEq<&'a str> for MetadataKey<VE>
[src]
fn eq(&self, other: &&'a str) -> bool
[src]
Performs a case-insensitive comparison of the string against the header name
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<'a, VE: ValueEncoding> PartialEq<MetadataKey<VE>> for &'a str
[src]
fn eq(&self, other: &MetadataKey<VE>) -> bool
[src]
Performs a case-insensitive comparison of the string against the header name
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<VE: Eq + ValueEncoding> Eq for MetadataKey<VE>
[src]
impl<VE: ValueEncoding> Display for MetadataKey<VE>
[src]
impl<VE: ValueEncoding> Debug for MetadataKey<VE>
[src]
impl<VE: Hash + ValueEncoding> Hash for MetadataKey<VE>
[src]
fn hash<__HVE: Hasher>(&self, state: &mut __HVE)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<VE: ValueEncoding> FromStr for MetadataKey<VE>
[src]
type Err = InvalidMetadataKey
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, InvalidMetadataKey>
[src]
impl<VE: ValueEncoding> Borrow<str> for MetadataKey<VE>
[src]
Auto Trait Implementations
impl<VE> Unpin for MetadataKey<VE> where
VE: Unpin,
VE: Unpin,
impl<VE> Sync for MetadataKey<VE> where
VE: Sync,
VE: Sync,
impl<VE> Send for MetadataKey<VE> where
VE: Send,
VE: Send,
impl<VE> UnwindSafe for MetadataKey<VE> where
VE: UnwindSafe,
VE: UnwindSafe,
impl<VE> RefUnwindSafe for MetadataKey<VE> where
VE: RefUnwindSafe,
VE: RefUnwindSafe,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,