#[repr(transparent)]
pub struct MetadataKey<VE: ValueEncoding> { /* private fields */ }
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!

Returns a str representation of the metadata key.

The returned string will always be lower case.

Trait Implementations

Converts this type into a shared reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Immutably borrows from an owned value. Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Converts to this type from the input type.
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
Feeds this value into the given [Hasher]. Read more
Feeds a slice of this type into the given [Hasher]. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Performs a case-insensitive comparison of the string against the header name

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Performs a case-insensitive comparison of the string against the header name

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

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");
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

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");
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
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
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