Struct tonic::metadata::MetadataKey [−][src]
#[repr(transparent)]pub struct MetadataKey<VE: ValueEncoding> { /* fields omitted */ }
Expand description
Represents a custom metadata field name.
MetadataKey
is used as the MetadataMap
key.
Implementations
Converts a slice of bytes to a MetadataKey
.
This function normalizes the input.
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
Performs the conversion.
Performs the conversion.
type Err = InvalidMetadataKey
type Err = InvalidMetadataKey
The associated error which can be returned from parsing.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
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");
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");
Auto Trait Implementations
impl<VE> RefUnwindSafe for MetadataKey<VE> where
VE: RefUnwindSafe,
impl<VE> Send for MetadataKey<VE> where
VE: Send,
impl<VE> Sync for MetadataKey<VE> where
VE: Sync,
impl<VE> Unpin for MetadataKey<VE> where
VE: Unpin,
impl<VE> UnwindSafe for MetadataKey<VE> where
VE: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more