Skip to main content

Metadata

Struct Metadata 

Source
pub struct Metadata { /* private fields */ }
Expand description

Application metadata preserving repeated keys and insertion order.

Implementations§

Source§

impl Metadata

Source

pub const fn new() -> Metadata

Creates an empty metadata collection without allocating.

Source

pub fn append_ascii( &mut self, key: &str, value: &str, ) -> Result<(), MetadataError>

Appends an ASCII entry, preserving earlier entries with the same key.

§Errors

Rejects malformed or protocol-reserved keys, -bin keys, and values containing non-printable ASCII. Rejection leaves the collection unchanged.

Source

pub fn append_binary( &mut self, key: &str, value: &[u8], ) -> Result<(), MetadataError>

Appends raw binary data under a -bin key.

§Errors

Rejects malformed or protocol-reserved keys and keys without a -bin suffix. Rejection leaves the collection unchanged.

Source

pub fn to_headers(&self) -> Vec<(String, String)>

Encodes raw binary entries as unpadded Base64 for HTTP/2 headers or trailers.

Source

pub fn append_header( &mut self, key: &str, value: &str, ) -> Result<(), MetadataError>

Decodes one application header, splitting comma-joined binary values. Incoming ASCII values accept HTTP horizontal tabs as well as printable ASCII.

§Errors

Rejects reserved keys, invalid ASCII or Base64. Rejection is atomic even when a later member of a comma-joined binary value is malformed.

Source

pub fn from_headers<'a>( headers: impl IntoIterator<Item = (&'a str, &'a str)>, ) -> Result<Metadata, MetadataError>

Builds application metadata from HTTP/2 headers, preserving duplicate order.

§Errors

Rejects any invalid application entry; protocol headers must be separated by the transport before invoking this constructor.

Source

pub fn iter(&self) -> impl Iterator<Item = (&str, &MetadataValue)>

Iterates over entries in insertion order, including repeated keys.

Source

pub fn get_all<'a>( &'a self, key: &'a str, ) -> impl Iterator<Item = &'a MetadataValue>

Iterates over all values matching an exact, case-sensitive key.

Source

pub const fn len(&self) -> usize

Returns the number of entries, counting repeated keys separately.

Source

pub const fn is_empty(&self) -> bool

Reports whether the collection contains no entries.

Trait Implementations§

Source§

impl Clone for Metadata

Source§

fn clone(&self) -> Metadata

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Metadata

Source§

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

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

impl Default for Metadata

Source§

fn default() -> Metadata

Returns the “default value” for a type. Read more
Source§

impl Eq for Metadata

Source§

impl PartialEq for Metadata

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Metadata

Auto Trait Implementations§

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.