pub struct Metadata { /* private fields */ }Expand description
Application metadata preserving repeated keys and insertion order.
Implementations§
Source§impl Metadata
impl Metadata
Sourcepub fn append_ascii(
&mut self,
key: &str,
value: &str,
) -> Result<(), MetadataError>
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.
Sourcepub fn append_binary(
&mut self,
key: &str,
value: &[u8],
) -> Result<(), MetadataError>
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.
Sourcepub fn to_headers(&self) -> Vec<(String, String)>
pub fn to_headers(&self) -> Vec<(String, String)>
Encodes raw binary entries as unpadded Base64 for HTTP/2 headers or trailers.
Sourcepub fn append_header(
&mut self,
key: &str,
value: &str,
) -> Result<(), MetadataError>
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.
Sourcepub fn from_headers<'a>(
headers: impl IntoIterator<Item = (&'a str, &'a str)>,
) -> Result<Metadata, MetadataError>
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.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &MetadataValue)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &MetadataValue)>
Iterates over entries in insertion order, including repeated keys.
Sourcepub fn get_all<'a>(
&'a self,
key: &'a str,
) -> impl Iterator<Item = &'a MetadataValue>
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.