Struct Headers

Source
pub struct Headers<'a> { /* private fields */ }
Expand description

A collection of Headers

Implementations§

Source§

impl<'a> Headers<'a>

Source

pub fn new() -> Self

Creates a new Headers-Instance, for performance reasons it is recommended to use the with_capacity method as that would avoid frequent reallocations

Source

pub fn with_capacity(cap: usize) -> Self

Creates the Headers-Object with the given Capacity prereserved for future Headers. This should be used when you already kind of know how many Headers this will hold, as it will avoid extra allocations in the future

Source

pub fn set<'b, K, V>(&mut self, key: K, value: V)
where K: Into<HeaderKey<'a>>, V: Into<HeaderValue<'a>>, 'b: 'a,

Sets the Value of the of the Header for the given Key to the given Value

§Behaviour

Checks if the Key is already present in the Collection and removes it if that is the case. Then adds the new Header to the End of the Collection

Source

pub fn append<K, V>(&mut self, key: K, value: V)
where K: Into<HeaderKey<'a>>, V: Into<HeaderValue<'a>>,

Appends the given Key-Value Pair to the end of the Collection, without checking if the Key is already present in the Collection

Source

pub fn remove<K>(&mut self, key: K)
where K: Into<HeaderKey<'a>>,

Removes the first Header, that matches the given Key, from the Collection

Source

pub fn get<K>(&self, key: K) -> Option<&HeaderValue<'a>>
where K: Into<HeaderKey<'a>>,

Searches the Collection for a Header that matches the given Key

Returns:

  • None: if no Header matches the Key
  • A Reference to the underlying Header-Value that belongs to the Key
Source

pub fn serialize(&self, buf: &mut Vec<u8>)

Serializes the Collection of Headers into the given Buffer by append to it

Source

pub fn get_max_value_size(&self) -> usize

Returns the Size in bytes of the biggest Value as text.

This means that all the Header-Values in this collection can fit in a buffer of this size.

Source

pub fn get_header_count(&self) -> usize

Returns the Number of Headers in this collection

Source

pub fn to_owned<'refed, 'owned>(&'refed self) -> Headers<'owned>

Clones all the assosicated Data to produce a new and independant Header-Collection

Trait Implementations§

Source§

impl<'a> Clone for Headers<'a>

Source§

fn clone(&self) -> Headers<'a>

Returns a duplicate 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<'a> Debug for Headers<'a>

Source§

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

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

impl<'a> Default for Headers<'a>

Source§

fn default() -> Self

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

impl<'a> PartialEq for Headers<'a>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> StructuralPartialEq for Headers<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Headers<'a>

§

impl<'a> RefUnwindSafe for Headers<'a>

§

impl<'a> Send for Headers<'a>

§

impl<'a> Sync for Headers<'a>

§

impl<'a> Unpin for Headers<'a>

§

impl<'a> UnwindSafe for Headers<'a>

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

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.