Struct MetadataValue
pub struct MetadataValue<VE>where
VE: ValueEncoding,{ /* private fields */ }Expand description
Represents a custom metadata field value.
MetadataValue is used as the MetadataMap value.
Implementations§
§impl<VE> MetadataValue<VE>where
VE: ValueEncoding,
impl<VE> MetadataValue<VE>where
VE: ValueEncoding,
pub fn from_static(src: &'static str) -> MetadataValue<VE>
pub fn from_static(src: &'static str) -> MetadataValue<VE>
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.
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.
pub fn to_bytes(&self) -> Result<Bytes, InvalidMetadataValueBytes>
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.
pub fn set_sensitive(&mut self, val: bool)
pub fn set_sensitive(&mut self, val: bool)
Mark that the metadata value represents sensitive information.
pub fn is_sensitive(&self) -> bool
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.
pub fn as_encoded_bytes(&self) -> &[u8] ⓘ
pub fn as_encoded_bytes(&self) -> &[u8] ⓘ
Converts a MetadataValue to a byte slice. For Binary values, the
return value is base64 encoded.
§impl MetadataValue<Ascii>
impl MetadataValue<Ascii>
pub fn from_key<KeyVE>(key: MetadataKey<KeyVE>) -> MetadataValue<Ascii>where
KeyVE: ValueEncoding,
pub fn from_key<KeyVE>(key: MetadataKey<KeyVE>) -> MetadataValue<Ascii>where
KeyVE: ValueEncoding,
Converts a MetadataKey into a MetadataValue<Ascii>.
Since every valid MetadataKey is a valid MetadataValue this is done infallibly.
pub fn len(&self) -> usize
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.
pub fn to_str(&self) -> Result<&str, ToStrError>
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.
§impl MetadataValue<Binary>
impl MetadataValue<Binary>
pub fn try_from_bytes(
src: &[u8],
) -> Result<MetadataValue<Binary>, InvalidMetadataValueBytes>
pub fn try_from_bytes( src: &[u8], ) -> Result<MetadataValue<Binary>, InvalidMetadataValueBytes>
Convert a byte slice to a MetadataValue<Binary>.
Trait Implementations§
§impl<VE> AsRef<[u8]> for MetadataValue<VE>where
VE: ValueEncoding,
impl<VE> AsRef<[u8]> for MetadataValue<VE>where
VE: ValueEncoding,
§impl<VE> Clone for MetadataValue<VE>where
VE: Clone + ValueEncoding,
impl<VE> Clone for MetadataValue<VE>where
VE: Clone + ValueEncoding,
§fn clone(&self) -> MetadataValue<VE>
fn clone(&self) -> MetadataValue<VE>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl<VE> Debug for MetadataValue<VE>where
VE: ValueEncoding,
impl<VE> Debug for MetadataValue<VE>where
VE: ValueEncoding,
§impl<'a, VE> From<&'a MetadataValue<VE>> for MetadataValue<VE>where
VE: ValueEncoding,
impl<'a, VE> From<&'a MetadataValue<VE>> for MetadataValue<VE>where
VE: ValueEncoding,
§fn from(t: &'a MetadataValue<VE>) -> MetadataValue<VE>
fn from(t: &'a MetadataValue<VE>) -> MetadataValue<VE>
§impl<KeyVE> From<MetadataKey<KeyVE>> for MetadataValue<Ascii>where
KeyVE: ValueEncoding,
impl<KeyVE> From<MetadataKey<KeyVE>> for MetadataValue<Ascii>where
KeyVE: ValueEncoding,
§fn from(h: MetadataKey<KeyVE>) -> MetadataValue<Ascii>
fn from(h: MetadataKey<KeyVE>) -> MetadataValue<Ascii>
§impl<VE> From<MetadataValue<VE>> for Byteswhere
VE: ValueEncoding,
impl<VE> From<MetadataValue<VE>> for Byteswhere
VE: ValueEncoding,
§fn from(value: MetadataValue<VE>) -> Bytes
fn from(value: MetadataValue<VE>) -> Bytes
§impl From<i16> for MetadataValue<Ascii>
impl From<i16> for MetadataValue<Ascii>
§fn from(num: i16) -> MetadataValue<Ascii>
fn from(num: i16) -> MetadataValue<Ascii>
§impl From<i32> for MetadataValue<Ascii>
impl From<i32> for MetadataValue<Ascii>
§fn from(num: i32) -> MetadataValue<Ascii>
fn from(num: i32) -> MetadataValue<Ascii>
§impl From<i64> for MetadataValue<Ascii>
impl From<i64> for MetadataValue<Ascii>
§fn from(num: i64) -> MetadataValue<Ascii>
fn from(num: i64) -> MetadataValue<Ascii>
§impl From<isize> for MetadataValue<Ascii>
impl From<isize> for MetadataValue<Ascii>
§fn from(num: isize) -> MetadataValue<Ascii>
fn from(num: isize) -> MetadataValue<Ascii>
§impl From<u16> for MetadataValue<Ascii>
impl From<u16> for MetadataValue<Ascii>
§fn from(num: u16) -> MetadataValue<Ascii>
fn from(num: u16) -> MetadataValue<Ascii>
§impl From<u32> for MetadataValue<Ascii>
impl From<u32> for MetadataValue<Ascii>
§fn from(num: u32) -> MetadataValue<Ascii>
fn from(num: u32) -> MetadataValue<Ascii>
§impl From<u64> for MetadataValue<Ascii>
impl From<u64> for MetadataValue<Ascii>
§fn from(num: u64) -> MetadataValue<Ascii>
fn from(num: u64) -> MetadataValue<Ascii>
§impl From<usize> for MetadataValue<Ascii>
impl From<usize> for MetadataValue<Ascii>
§fn from(num: usize) -> MetadataValue<Ascii>
fn from(num: usize) -> MetadataValue<Ascii>
§impl FromStr for MetadataValue<Ascii>
impl FromStr for MetadataValue<Ascii>
§type Err = InvalidMetadataValue
type Err = InvalidMetadataValue
§impl Hash for MetadataValue<Ascii>
impl Hash for MetadataValue<Ascii>
§impl Hash for MetadataValue<Binary>
impl Hash for MetadataValue<Binary>
§impl<VE> Ord for MetadataValue<VE>where
VE: ValueEncoding,
impl<VE> Ord for MetadataValue<VE>where
VE: ValueEncoding,
§fn cmp(&self, other: &MetadataValue<VE>) -> Ordering
fn cmp(&self, other: &MetadataValue<VE>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
§impl<'a, VE, T> PartialEq<&'a T> for MetadataValue<VE>
impl<'a, VE, T> PartialEq<&'a T> for MetadataValue<VE>
§impl<VE> PartialEq<[u8]> for MetadataValue<VE>where
VE: ValueEncoding,
impl<VE> PartialEq<[u8]> for MetadataValue<VE>where
VE: ValueEncoding,
§impl<VE> PartialEq<MetadataValue<VE>> for &MetadataValue<VE>where
VE: ValueEncoding,
impl<VE> PartialEq<MetadataValue<VE>> for &MetadataValue<VE>where
VE: ValueEncoding,
§impl<VE> PartialEq<MetadataValue<VE>> for &strwhere
VE: ValueEncoding,
impl<VE> PartialEq<MetadataValue<VE>> for &strwhere
VE: ValueEncoding,
§impl<VE> PartialEq<MetadataValue<VE>> for [u8]where
VE: ValueEncoding,
impl<VE> PartialEq<MetadataValue<VE>> for [u8]where
VE: ValueEncoding,
§impl<VE> PartialEq<MetadataValue<VE>> for Stringwhere
VE: ValueEncoding,
impl<VE> PartialEq<MetadataValue<VE>> for Stringwhere
VE: ValueEncoding,
§impl<VE> PartialEq<MetadataValue<VE>> for strwhere
VE: ValueEncoding,
impl<VE> PartialEq<MetadataValue<VE>> for strwhere
VE: ValueEncoding,
§impl<VE> PartialEq<String> for MetadataValue<VE>where
VE: ValueEncoding,
impl<VE> PartialEq<String> for MetadataValue<VE>where
VE: ValueEncoding,
§impl<VE> PartialEq<str> for MetadataValue<VE>where
VE: ValueEncoding,
impl<VE> PartialEq<str> for MetadataValue<VE>where
VE: ValueEncoding,
§impl<VE> PartialEq for MetadataValue<VE>where
VE: ValueEncoding,
impl<VE> PartialEq for MetadataValue<VE>where
VE: ValueEncoding,
§impl<'a, VE, T> PartialOrd<&'a T> for MetadataValue<VE>
impl<'a, VE, T> PartialOrd<&'a T> for MetadataValue<VE>
§impl<VE> PartialOrd<[u8]> for MetadataValue<VE>where
VE: ValueEncoding,
impl<VE> PartialOrd<[u8]> for MetadataValue<VE>where
VE: ValueEncoding,
§impl<VE> PartialOrd<MetadataValue<VE>> for &MetadataValue<VE>where
VE: ValueEncoding,
impl<VE> PartialOrd<MetadataValue<VE>> for &MetadataValue<VE>where
VE: ValueEncoding,
§impl<VE> PartialOrd<MetadataValue<VE>> for &strwhere
VE: ValueEncoding,
impl<VE> PartialOrd<MetadataValue<VE>> for &strwhere
VE: ValueEncoding,
§impl<VE> PartialOrd<MetadataValue<VE>> for [u8]where
VE: ValueEncoding,
impl<VE> PartialOrd<MetadataValue<VE>> for [u8]where
VE: ValueEncoding,
§impl<VE> PartialOrd<MetadataValue<VE>> for Stringwhere
VE: ValueEncoding,
impl<VE> PartialOrd<MetadataValue<VE>> for Stringwhere
VE: ValueEncoding,
§impl<VE> PartialOrd<MetadataValue<VE>> for strwhere
VE: ValueEncoding,
impl<VE> PartialOrd<MetadataValue<VE>> for strwhere
VE: ValueEncoding,
§impl<VE> PartialOrd<String> for MetadataValue<VE>where
VE: ValueEncoding,
impl<VE> PartialOrd<String> for MetadataValue<VE>where
VE: ValueEncoding,
§impl<VE> PartialOrd<str> for MetadataValue<VE>where
VE: ValueEncoding,
impl<VE> PartialOrd<str> for MetadataValue<VE>where
VE: ValueEncoding,
§impl<VE> PartialOrd for MetadataValue<VE>where
VE: ValueEncoding,
impl<VE> PartialOrd for MetadataValue<VE>where
VE: ValueEncoding,
§impl<VE> TryFrom<&[u8]> for MetadataValue<VE>where
VE: ValueEncoding,
Attempt to convert a byte slice to a MetadataValue.
impl<VE> TryFrom<&[u8]> for MetadataValue<VE>where
VE: ValueEncoding,
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.
§type Error = InvalidMetadataValueBytes
type Error = InvalidMetadataValueBytes
§fn try_from(
src: &[u8],
) -> Result<MetadataValue<VE>, <MetadataValue<VE> as TryFrom<&[u8]>>::Error>
fn try_from( src: &[u8], ) -> Result<MetadataValue<VE>, <MetadataValue<VE> as TryFrom<&[u8]>>::Error>
§impl<VE, const N: usize> TryFrom<&[u8; N]> for MetadataValue<VE>where
VE: ValueEncoding,
Attempt to convert a byte slice to a MetadataValue.
impl<VE, const N: usize> TryFrom<&[u8; N]> for MetadataValue<VE>where
VE: ValueEncoding,
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.
§type Error = InvalidMetadataValueBytes
type Error = InvalidMetadataValueBytes
§impl<'a> TryFrom<&'a String> for MetadataValue<Ascii>
Attempt to convert a string to a MetadataValue<Ascii>.
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
type Error = InvalidMetadataValue
§impl<'a> TryFrom<&'a str> for MetadataValue<Ascii>
Attempt to convert a string to a MetadataValue<Ascii>.
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
type Error = InvalidMetadataValue
§impl<VE> TryFrom<Bytes> for MetadataValue<VE>where
VE: ValueEncoding,
Attempt to convert a Bytes buffer to a MetadataValue.
impl<VE> TryFrom<Bytes> for MetadataValue<VE>where
VE: ValueEncoding,
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
type Error = InvalidMetadataValueBytes
§fn try_from(
src: Bytes,
) -> Result<MetadataValue<VE>, <MetadataValue<VE> as TryFrom<Bytes>>::Error>
fn try_from( src: Bytes, ) -> Result<MetadataValue<VE>, <MetadataValue<VE> as TryFrom<Bytes>>::Error>
§impl TryFrom<String> for MetadataValue<Ascii>
Attempt to convert a string to a MetadataValue<Ascii>.
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
type Error = InvalidMetadataValue
§impl<VE> TryFrom<Vec<u8>> for MetadataValue<VE>where
VE: ValueEncoding,
Attempt to convert a Vec of bytes to a MetadataValue.
impl<VE> TryFrom<Vec<u8>> for MetadataValue<VE>where
VE: ValueEncoding,
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
type Error = InvalidMetadataValueBytes
impl<VE> Eq for MetadataValue<VE>where
VE: ValueEncoding,
Auto Trait Implementations§
impl<VE> !Freeze for MetadataValue<VE>
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§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more§impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
fn rama_try_from(value: T) -> Result<U, <U as RamaTryFrom<T>>::Error>
§impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
type Error = <U as RamaTryFrom<T, CrateMarker>>::Error
fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>
Source§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
self into the result. Lower case
letters are used (e.g. f9b4ca)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
self into the result. Upper case
letters are used (e.g. F9B4CA)