Struct madsim_tonic::metadata::MetadataKey
source · [−]#[repr(transparent)]pub struct MetadataKey<VE> where
VE: ValueEncoding, { /* private fields */ }
Expand description
Represents a custom metadata field name.
MetadataKey
is used as the MetadataMap
key.
Implementations
sourceimpl<VE> MetadataKey<VE> where
VE: ValueEncoding,
impl<VE> MetadataKey<VE> where
VE: ValueEncoding,
sourcepub fn from_bytes(src: &[u8]) -> Result<MetadataKey<VE>, InvalidMetadataKey>
pub fn from_bytes(src: &[u8]) -> Result<MetadataKey<VE>, InvalidMetadataKey>
Converts a slice of bytes to a MetadataKey
.
This function normalizes the input.
sourcepub fn from_static(src: &'static str) -> MetadataKey<VE>
pub fn from_static(src: &'static str) -> MetadataKey<VE>
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
sourceimpl<VE> AsRef<str> for MetadataKey<VE> where
VE: ValueEncoding,
impl<VE> AsRef<str> for MetadataKey<VE> where
VE: ValueEncoding,
sourceimpl<VE> Borrow<str> for MetadataKey<VE> where
VE: ValueEncoding,
impl<VE> Borrow<str> for MetadataKey<VE> where
VE: ValueEncoding,
sourceimpl<VE> Clone for MetadataKey<VE> where
VE: Clone + ValueEncoding,
impl<VE> Clone for MetadataKey<VE> where
VE: Clone + ValueEncoding,
sourcefn clone(&self) -> MetadataKey<VE>
fn clone(&self) -> MetadataKey<VE>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<VE> Debug for MetadataKey<VE> where
VE: ValueEncoding,
impl<VE> Debug for MetadataKey<VE> where
VE: ValueEncoding,
sourceimpl<VE> Display for MetadataKey<VE> where
VE: ValueEncoding,
impl<VE> Display for MetadataKey<VE> where
VE: ValueEncoding,
sourceimpl<'a, VE> From<&'a MetadataKey<VE>> for MetadataKey<VE> where
VE: ValueEncoding,
impl<'a, VE> From<&'a MetadataKey<VE>> for MetadataKey<VE> where
VE: ValueEncoding,
sourcefn from(src: &'a MetadataKey<VE>) -> MetadataKey<VE>
fn from(src: &'a MetadataKey<VE>) -> MetadataKey<VE>
Converts to this type from the input type.
sourceimpl<KeyVE> From<MetadataKey<KeyVE>> for MetadataValue<Ascii> where
KeyVE: ValueEncoding,
impl<KeyVE> From<MetadataKey<KeyVE>> for MetadataValue<Ascii> where
KeyVE: ValueEncoding,
sourcefn from(h: MetadataKey<KeyVE>) -> MetadataValue<Ascii>
fn from(h: MetadataKey<KeyVE>) -> MetadataValue<Ascii>
Converts to this type from the input type.
sourceimpl<VE> From<MetadataKey<VE>> for Bytes where
VE: ValueEncoding,
impl<VE> From<MetadataKey<VE>> for Bytes where
VE: ValueEncoding,
sourcefn from(name: MetadataKey<VE>) -> Bytes
fn from(name: MetadataKey<VE>) -> Bytes
Converts to this type from the input type.
sourceimpl<VE> FromStr for MetadataKey<VE> where
VE: ValueEncoding,
impl<VE> FromStr for MetadataKey<VE> where
VE: ValueEncoding,
type Err = InvalidMetadataKey
type Err = InvalidMetadataKey
The associated error which can be returned from parsing.
sourcefn from_str(s: &str) -> Result<MetadataKey<VE>, InvalidMetadataKey>
fn from_str(s: &str) -> Result<MetadataKey<VE>, InvalidMetadataKey>
Parses a string s
to return a value of this type. Read more
sourceimpl<VE> Hash for MetadataKey<VE> where
VE: Hash + ValueEncoding,
impl<VE> Hash for MetadataKey<VE> where
VE: Hash + ValueEncoding,
sourceimpl<'a, VE> PartialEq<&'a MetadataKey<VE>> for MetadataKey<VE> where
VE: ValueEncoding,
impl<'a, VE> PartialEq<&'a MetadataKey<VE>> for MetadataKey<VE> where
VE: ValueEncoding,
sourceimpl<'a, VE> PartialEq<&'a str> for MetadataKey<VE> where
VE: ValueEncoding,
impl<'a, VE> PartialEq<&'a str> for MetadataKey<VE> where
VE: ValueEncoding,
sourceimpl<'a, VE> PartialEq<MetadataKey<VE>> for &'a MetadataKey<VE> where
VE: ValueEncoding,
impl<'a, VE> PartialEq<MetadataKey<VE>> for &'a MetadataKey<VE> where
VE: ValueEncoding,
sourceimpl<VE> PartialEq<MetadataKey<VE>> for MetadataKey<VE> where
VE: PartialEq<VE> + ValueEncoding,
impl<VE> PartialEq<MetadataKey<VE>> for MetadataKey<VE> where
VE: PartialEq<VE> + ValueEncoding,
sourcefn eq(&self, other: &MetadataKey<VE>) -> bool
fn eq(&self, other: &MetadataKey<VE>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &MetadataKey<VE>) -> bool
fn ne(&self, other: &MetadataKey<VE>) -> bool
This method tests for !=
.
sourceimpl<VE> PartialEq<MetadataKey<VE>> for str where
VE: ValueEncoding,
impl<VE> PartialEq<MetadataKey<VE>> for str where
VE: ValueEncoding,
sourcefn eq(&self, other: &MetadataKey<VE>) -> bool
fn eq(&self, other: &MetadataKey<VE>) -> 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");
sourceimpl<'a, VE> PartialEq<MetadataKey<VE>> for &'a str where
VE: ValueEncoding,
impl<'a, VE> PartialEq<MetadataKey<VE>> for &'a str where
VE: ValueEncoding,
sourceimpl<VE> PartialEq<str> for MetadataKey<VE> where
VE: ValueEncoding,
impl<VE> PartialEq<str> for MetadataKey<VE> where
VE: ValueEncoding,
sourcefn 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");
impl<VE> Eq for MetadataKey<VE> where
VE: Eq + ValueEncoding,
impl<VE> StructuralEq for MetadataKey<VE> where
VE: ValueEncoding,
impl<VE> StructuralPartialEq for MetadataKey<VE> where
VE: ValueEncoding,
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourcefn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourceimpl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
sourcefn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message T
in a tonic::Request
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
T: Future, type Output = <T as Future>::Output;
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more