pub struct MetadataValue<VE: ValueEncoding> { /* private fields */ }
Expand description

Represents a custom metadata field value.

MetadataValue is used as the MetadataMap value.

Implementations§

source§

impl<VE: ValueEncoding> MetadataValue<VE>

source

pub fn from_static(src: &'static str) -> Self

Convert a static string to a MetadataValue.

This function will not perform any copying, however the string is checked to ensure that no invalid characters are present.

For Ascii values, only visible ASCII characters (32-127) are permitted. For Binary values, the string must be valid base64.

§Panics

This function panics if the argument contains invalid metadata value characters.

§Examples
let val = AsciiMetadataValue::from_static("hello");
assert_eq!(val, "hello");
let val = BinaryMetadataValue::from_static("SGVsbG8hIQ==");
assert_eq!(val, "Hello!!");
source

pub fn try_from_bytes(src: &[u8]) -> Result<Self, InvalidMetadataValueBytes>

👎Deprecated: Use TryFrom instead

Attempt to convert a byte slice to a MetadataValue.

For Ascii metadata values, If the argument contains invalid metadata value bytes, an error is returned. Only byte values between 32 and 255 (inclusive) are permitted, excluding byte 127 (DEL).

For Binary metadata values this method cannot fail. See also the Binary only version of this method from_bytes.

§Examples
let val = AsciiMetadataValue::try_from_bytes(b"hello\xfa").unwrap();
assert_eq!(val, &b"hello\xfa"[..]);

An invalid value

let val = AsciiMetadataValue::try_from_bytes(b"\n");
assert!(val.is_err());
source

pub fn from_shared(src: Bytes) -> Result<Self, InvalidMetadataValueBytes>

👎Deprecated: Use TryFrom instead

Attempt to convert a Bytes buffer to a MetadataValue.

For MetadataValue<Ascii>, if the argument contains invalid metadata value bytes, an error is returned. Only byte values between 32 and 255 (inclusive) are permitted, excluding byte 127 (DEL).

For MetadataValue<Binary>, if the argument is not valid base64, an error is returned. In use cases where the input is not base64 encoded, use from_bytes; if the value has to be encoded it’s not possible to share the memory anyways.

source

pub unsafe fn from_shared_unchecked(src: Bytes) -> Self

Convert a Bytes directly into a MetadataValue without validating. For MetadataValue<Binary> the provided parameter must be base64 encoded without padding bytes at the end.

§Safety

This function does NOT validate that illegal bytes are not contained within the buffer.

source

pub fn is_empty(&self) -> bool

Returns true if the MetadataValue has a length of zero bytes.

§Examples
let val = AsciiMetadataValue::from_static("");
assert!(val.is_empty());

let val = AsciiMetadataValue::from_static("hello");
assert!(!val.is_empty());
source

pub fn to_bytes(&self) -> Result<Bytes, InvalidMetadataValueBytes>

Converts a MetadataValue to a Bytes buffer. This method cannot fail for Ascii values. For Ascii values, as_bytes is more convenient to use.

§Examples
let val = AsciiMetadataValue::from_static("hello");
assert_eq!(val.to_bytes().unwrap().as_ref(), b"hello");
let val = BinaryMetadataValue::from_bytes(b"hello");
assert_eq!(val.to_bytes().unwrap().as_ref(), b"hello");
source

pub fn set_sensitive(&mut self, val: bool)

Mark that the metadata value represents sensitive information.

§Examples
let mut val = AsciiMetadataValue::from_static("my secret");

val.set_sensitive(true);
assert!(val.is_sensitive());

val.set_sensitive(false);
assert!(!val.is_sensitive());
source

pub fn is_sensitive(&self) -> bool

Returns true if the value represents sensitive data.

Sensitive data could represent passwords or other data that should not be stored on disk or in memory. This setting can be used by components like caches to avoid storing the value. HPACK encoders must set the metadata field to never index when is_sensitive returns true.

Note that sensitivity is not factored into equality or ordering.

§Examples
let mut val = AsciiMetadataValue::from_static("my secret");

val.set_sensitive(true);
assert!(val.is_sensitive());

val.set_sensitive(false);
assert!(!val.is_sensitive());
source

pub fn as_encoded_bytes(&self) -> &[u8]

Converts a MetadataValue to a byte slice. For Binary values, the return value is base64 encoded.

§Examples
let val = AsciiMetadataValue::from_static("hello");
assert_eq!(val.as_encoded_bytes(), b"hello");
let val = BinaryMetadataValue::from_bytes(b"Hello!");
assert_eq!(val.as_encoded_bytes(), b"SGVsbG8h");
source§

impl MetadataValue<Ascii>

source

pub fn from_str(src: &str) -> Result<Self, InvalidMetadataValue>

👎Deprecated: Use TryFrom or FromStr instead

Attempt to convert a string to a MetadataValue<Ascii>.

If the argument contains invalid metadata value characters, an error is returned. Only visible ASCII characters (32-127) are permitted. Use from_bytes to create a MetadataValue that includes opaque octets (128-255).

§Examples
let val = AsciiMetadataValue::from_str("hello").unwrap();
assert_eq!(val, "hello");

An invalid value

let val = AsciiMetadataValue::from_str("\n");
assert!(val.is_err());
source

pub fn from_key<KeyVE: ValueEncoding>(key: MetadataKey<KeyVE>) -> Self

Converts a MetadataKey into a MetadataValue<Ascii>.

Since every valid MetadataKey is a valid MetadataValue this is done infallibly.

§Examples
let val = AsciiMetadataValue::from_key::<Ascii>("accept".parse().unwrap());
assert_eq!(val, AsciiMetadataValue::try_from(b"accept").unwrap());
source

pub fn len(&self) -> usize

Returns the length of self, in bytes.

This method is not available for MetadataValue<Binary> because that cannot be implemented in constant time, which most people would probably expect. To get the length of MetadataValue<Binary>, convert it to a Bytes value and measure its length.

§Examples
let val = AsciiMetadataValue::from_static("hello");
assert_eq!(val.len(), 5);
source

pub fn to_str(&self) -> Result<&str, ToStrError>

Yields a &str slice if the MetadataValue only contains visible ASCII chars.

This function will perform a scan of the metadata value, checking all the characters.

§Examples
let val = AsciiMetadataValue::from_static("hello");
assert_eq!(val.to_str().unwrap(), "hello");
source

pub fn as_bytes(&self) -> &[u8]

Converts a MetadataValue to a byte slice. For Binary values, use to_bytes.

§Examples
let val = AsciiMetadataValue::from_static("hello");
assert_eq!(val.as_bytes(), b"hello");
source§

impl MetadataValue<Binary>

source

pub fn from_bytes(src: &[u8]) -> Self

Convert a byte slice to a MetadataValue<Binary>.

§Examples
let val = BinaryMetadataValue::from_bytes(b"hello\xfa");
assert_eq!(val, &b"hello\xfa"[..]);

Trait Implementations§

source§

impl<VE: ValueEncoding> AsRef<[u8]> for MetadataValue<VE>

source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<VE: Clone + ValueEncoding> Clone for MetadataValue<VE>

source§

fn clone(&self) -> MetadataValue<VE>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<VE: ValueEncoding> Debug for MetadataValue<VE>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a, VE: ValueEncoding> From<&'a MetadataValue<VE>> for MetadataValue<VE>

source§

fn from(t: &'a MetadataValue<VE>) -> Self

Converts to this type from the input type.
source§

impl<KeyVE: ValueEncoding> From<MetadataKey<KeyVE>> for MetadataValue<Ascii>

source§

fn from(h: MetadataKey<KeyVE>) -> MetadataValue<Ascii>

Converts to this type from the input type.
source§

impl<VE: ValueEncoding> From<MetadataValue<VE>> for Bytes

source§

fn from(value: MetadataValue<VE>) -> Bytes

Converts to this type from the input type.
source§

impl From<i16> for MetadataValue<Ascii>

source§

fn from(num: i16) -> MetadataValue<Ascii>

Converts to this type from the input type.
source§

impl From<i32> for MetadataValue<Ascii>

source§

fn from(num: i32) -> MetadataValue<Ascii>

Converts to this type from the input type.
source§

impl From<i64> for MetadataValue<Ascii>

source§

fn from(num: i64) -> MetadataValue<Ascii>

Converts to this type from the input type.
source§

impl From<isize> for MetadataValue<Ascii>

source§

fn from(num: isize) -> MetadataValue<Ascii>

Converts to this type from the input type.
source§

impl From<u16> for MetadataValue<Ascii>

source§

fn from(num: u16) -> MetadataValue<Ascii>

Converts to this type from the input type.
source§

impl From<u32> for MetadataValue<Ascii>

source§

fn from(num: u32) -> MetadataValue<Ascii>

Converts to this type from the input type.
source§

impl From<u64> for MetadataValue<Ascii>

source§

fn from(num: u64) -> MetadataValue<Ascii>

Converts to this type from the input type.
source§

impl From<usize> for MetadataValue<Ascii>

source§

fn from(num: usize) -> MetadataValue<Ascii>

Converts to this type from the input type.
source§

impl FromStr for MetadataValue<Ascii>

§

type Err = InvalidMetadataValue

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<MetadataValue<Ascii>, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for MetadataValue<Ascii>

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Hash for MetadataValue<Binary>

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<VE: ValueEncoding> Ord for MetadataValue<VE>

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<'a, VE: ValueEncoding, T: ?Sized> PartialEq<&'a T> for MetadataValue<VE>
where MetadataValue<VE>: PartialEq<T>,

source§

fn eq(&self, other: &&'a T) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<VE: ValueEncoding> PartialEq<[u8]> for MetadataValue<VE>

source§

fn eq(&self, other: &[u8]) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, VE: ValueEncoding> PartialEq<MetadataValue<VE>> for &'a MetadataValue<VE>

source§

fn eq(&self, other: &MetadataValue<VE>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, VE: ValueEncoding> PartialEq<MetadataValue<VE>> for &'a str

source§

fn eq(&self, other: &MetadataValue<VE>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<VE: ValueEncoding> PartialEq<MetadataValue<VE>> for [u8]

source§

fn eq(&self, other: &MetadataValue<VE>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<VE: ValueEncoding> PartialEq<MetadataValue<VE>> for String

source§

fn eq(&self, other: &MetadataValue<VE>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<VE: ValueEncoding> PartialEq<MetadataValue<VE>> for str

source§

fn eq(&self, other: &MetadataValue<VE>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<VE: ValueEncoding> PartialEq<String> for MetadataValue<VE>

source§

fn eq(&self, other: &String) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<VE: ValueEncoding> PartialEq<str> for MetadataValue<VE>

source§

fn eq(&self, other: &str) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<VE: ValueEncoding> PartialEq for MetadataValue<VE>

source§

fn eq(&self, other: &MetadataValue<VE>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, VE: ValueEncoding, T: ?Sized> PartialOrd<&'a T> for MetadataValue<VE>
where MetadataValue<VE>: PartialOrd<T>,

source§

fn partial_cmp(&self, other: &&'a T) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<VE: ValueEncoding> PartialOrd<[u8]> for MetadataValue<VE>

source§

fn partial_cmp(&self, other: &[u8]) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, VE: ValueEncoding> PartialOrd<MetadataValue<VE>> for &'a MetadataValue<VE>

source§

fn partial_cmp(&self, other: &MetadataValue<VE>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, VE: ValueEncoding> PartialOrd<MetadataValue<VE>> for &'a str

source§

fn partial_cmp(&self, other: &MetadataValue<VE>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<VE: ValueEncoding> PartialOrd<MetadataValue<VE>> for [u8]

source§

fn partial_cmp(&self, other: &MetadataValue<VE>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<VE: ValueEncoding> PartialOrd<MetadataValue<VE>> for String

source§

fn partial_cmp(&self, other: &MetadataValue<VE>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<VE: ValueEncoding> PartialOrd<MetadataValue<VE>> for str

source§

fn partial_cmp(&self, other: &MetadataValue<VE>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<VE: ValueEncoding> PartialOrd<String> for MetadataValue<VE>

source§

fn partial_cmp(&self, other: &String) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<VE: ValueEncoding> PartialOrd<str> for MetadataValue<VE>

source§

fn partial_cmp(&self, other: &str) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<VE: ValueEncoding> PartialOrd for MetadataValue<VE>

source§

fn partial_cmp(&self, other: &MetadataValue<VE>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, VE: ValueEncoding> TryFrom<&'a [u8]> for MetadataValue<VE>

Attempt to convert a byte slice to a MetadataValue.

For Ascii metadata values, If the argument contains invalid metadata value bytes, an error is returned. Only byte values between 32 and 255 (inclusive) are permitted, excluding byte 127 (DEL).

For Binary metadata values this method cannot fail. See also the Binary only version of this method from_bytes.

§Examples

let val = AsciiMetadataValue::try_from(b"hello\xfa").unwrap();
assert_eq!(val, &b"hello\xfa"[..]);

An invalid value

let val = AsciiMetadataValue::try_from(b"\n");
assert!(val.is_err());
§

type Error = InvalidMetadataValueBytes

The type returned in the event of a conversion error.
source§

fn try_from(src: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a, VE: ValueEncoding, const N: usize> TryFrom<&'a [u8; N]> for MetadataValue<VE>

Attempt to convert a byte slice to a MetadataValue.

For Ascii metadata values, If the argument contains invalid metadata value bytes, an error is returned. Only byte values between 32 and 255 (inclusive) are permitted, excluding byte 127 (DEL).

For Binary metadata values this method cannot fail. See also the Binary only version of this method from_bytes.

§Examples

let val = AsciiMetadataValue::try_from(b"hello\xfa").unwrap();
assert_eq!(val, &b"hello\xfa"[..]);

An invalid value

let val = AsciiMetadataValue::try_from(b"\n");
assert!(val.is_err());
§

type Error = InvalidMetadataValueBytes

The type returned in the event of a conversion error.
source§

fn try_from(src: &[u8; N]) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a String> for MetadataValue<Ascii>

Attempt to convert a string to a MetadataValue<Ascii>.

If the argument contains invalid metadata value characters, an error is returned. Only visible ASCII characters (32-127) are permitted. Use from_bytes to create a MetadataValue that includes opaque octets (128-255).

§

type Error = InvalidMetadataValue

The type returned in the event of a conversion error.
source§

fn try_from(s: &'a String) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a str> for MetadataValue<Ascii>

Attempt to convert a string to a MetadataValue<Ascii>.

If the argument contains invalid metadata value characters, an error is returned. Only visible ASCII characters (32-127) are permitted. Use from_bytes to create a MetadataValue that includes opaque octets (128-255).

§

type Error = InvalidMetadataValue

The type returned in the event of a conversion error.
source§

fn try_from(s: &'a str) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<VE: ValueEncoding> TryFrom<Bytes> for MetadataValue<VE>

Attempt to convert a Bytes buffer to a MetadataValue.

For MetadataValue<Ascii>, if the argument contains invalid metadata value bytes, an error is returned. Only byte values between 32 and 255 (inclusive) are permitted, excluding byte 127 (DEL).

For MetadataValue<Binary>, if the argument is not valid base64, an error is returned. In use cases where the input is not base64 encoded, use from_bytes; if the value has to be encoded it’s not possible to share the memory anyways.

§

type Error = InvalidMetadataValueBytes

The type returned in the event of a conversion error.
source§

fn try_from(src: Bytes) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<String> for MetadataValue<Ascii>

Attempt to convert a string to a MetadataValue<Ascii>.

If the argument contains invalid metadata value characters, an error is returned. Only visible ASCII characters (32-127) are permitted. Use from_bytes to create a MetadataValue that includes opaque octets (128-255).

§

type Error = InvalidMetadataValue

The type returned in the event of a conversion error.
source§

fn try_from(s: String) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<VE: ValueEncoding> TryFrom<Vec<u8>> for MetadataValue<VE>

Attempt to convert a Vec of bytes to a MetadataValue.

For MetadataValue<Ascii>, if the argument contains invalid metadata value bytes, an error is returned. Only byte values between 32 and 255 (inclusive) are permitted, excluding byte 127 (DEL).

For MetadataValue<Binary>, if the argument is not valid base64, an error is returned. In use cases where the input is not base64 encoded, use from_bytes; if the value has to be encoded it’s not possible to share the memory anyways.

§

type Error = InvalidMetadataValueBytes

The type returned in the event of a conversion error.
source§

fn try_from(src: Vec<u8>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<VE: ValueEncoding> Eq for MetadataValue<VE>

Auto Trait Implementations§

§

impl<VE> RefUnwindSafe for MetadataValue<VE>
where VE: RefUnwindSafe,

§

impl<VE> Send for MetadataValue<VE>
where VE: Send,

§

impl<VE> Sync for MetadataValue<VE>
where VE: Sync,

§

impl<VE> Unpin for MetadataValue<VE>
where VE: Unpin,

§

impl<VE> UnwindSafe for MetadataValue<VE>
where VE: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromRef<T> for T
where T: Clone,

source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more