Type Alias tonic::metadata::AsciiMetadataKey
source · pub type AsciiMetadataKey = MetadataKey<Ascii>;
Expand description
An ascii metadata key.
Aliased Type§
struct AsciiMetadataKey { /* private fields */ }
Implementations
source§impl<VE: ValueEncoding> MetadataKey<VE>
impl<VE: ValueEncoding> MetadataKey<VE>
sourcepub fn from_bytes(src: &[u8]) -> Result<Self, InvalidMetadataKey>
pub fn from_bytes(src: &[u8]) -> Result<Self, InvalidMetadataKey>
Converts a slice of bytes to a MetadataKey
.
This function normalizes the input.
sourcepub fn from_static(src: &'static str) -> Self
pub fn from_static(src: &'static str) -> Self
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!
Trait Implementations
source§impl<VE: ValueEncoding> AsRef<[u8]> for MetadataKey<VE>
impl<VE: ValueEncoding> AsRef<[u8]> for MetadataKey<VE>
source§impl<VE: ValueEncoding> AsRef<str> for MetadataKey<VE>
impl<VE: ValueEncoding> AsRef<str> for MetadataKey<VE>
source§impl<VE: ValueEncoding> Borrow<str> for MetadataKey<VE>
impl<VE: ValueEncoding> Borrow<str> for MetadataKey<VE>
source§impl<VE: Clone + ValueEncoding> Clone for MetadataKey<VE>
impl<VE: Clone + ValueEncoding> Clone for MetadataKey<VE>
source§fn clone(&self) -> MetadataKey<VE>
fn clone(&self) -> MetadataKey<VE>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<VE: ValueEncoding> Debug for MetadataKey<VE>
impl<VE: ValueEncoding> Debug for MetadataKey<VE>
source§impl<VE: ValueEncoding> Display for MetadataKey<VE>
impl<VE: ValueEncoding> Display for MetadataKey<VE>
source§impl<'a, VE: ValueEncoding> From<&'a MetadataKey<VE>> for MetadataKey<VE>
impl<'a, VE: ValueEncoding> From<&'a MetadataKey<VE>> for MetadataKey<VE>
source§fn from(src: &'a MetadataKey<VE>) -> MetadataKey<VE>
fn from(src: &'a MetadataKey<VE>) -> MetadataKey<VE>
Converts to this type from the input type.
source§impl<VE: ValueEncoding> FromStr for MetadataKey<VE>
impl<VE: ValueEncoding> FromStr for MetadataKey<VE>
§type Err = InvalidMetadataKey
type Err = InvalidMetadataKey
The associated error which can be returned from parsing.
source§impl<VE: Hash + ValueEncoding> Hash for MetadataKey<VE>
impl<VE: Hash + ValueEncoding> Hash for MetadataKey<VE>
source§impl<'a, VE: ValueEncoding> PartialEq<&'a MetadataKey<VE>> for MetadataKey<VE>
impl<'a, VE: ValueEncoding> PartialEq<&'a MetadataKey<VE>> for MetadataKey<VE>
source§impl<'a, VE: ValueEncoding> PartialEq<&'a str> for MetadataKey<VE>
impl<'a, VE: ValueEncoding> PartialEq<&'a str> for MetadataKey<VE>
source§impl<VE: ValueEncoding> PartialEq<str> for MetadataKey<VE>
impl<VE: ValueEncoding> PartialEq<str> for MetadataKey<VE>
source§fn eq(&self, other: &str) -> bool
fn eq(&self, other: &str) -> bool
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");