Skip to main content

Entry

Enum Entry 

Source
pub enum Entry<'a> {
    Vacant(VacantEntry<'a>),
    Occupied(OccupiedEntry<'a>),
}
Expand description

A view into the storage for a particular header name

Variants§

§

Vacant(VacantEntry<'a>)

A mutable view into the location that header values would be inserted into this Headers for the specified HeaderName

§

Occupied(OccupiedEntry<'a>)

A mutable view into the header values are stored for the specified HeaderName

Implementations§

Source§

impl<'a> Entry<'a>

Source

pub fn name(&self) -> HeaderName<'_>

retrieve the HeaderName for this entry.

Source

pub fn insert(self, values: impl Into<HeaderValues>) -> &'a mut HeaderValues

Sets the value of the entry, and returns a mutable reference to the inserted value.

Note that this drops any previous occupied value.

Source

pub fn append(self, values: impl Into<HeaderValues>) -> &'a mut HeaderValues

Sets the value of the entry if it is vacant, and appends the new header values to the previous ones if occupied. Returns a mutable reference to the inserted or updated value.

Source

pub fn or_insert_with<V: Into<HeaderValues>>( self, values: impl FnOnce() -> V, ) -> &'a mut HeaderValues

Sets the value if previously vacant. The provided function is only executed if the entry is vacant.

Source

pub fn or_insert(self, values: impl Into<HeaderValues>) -> &'a mut HeaderValues

Sets the value if previously vacant. See also Entry::or_insert_with if constructing the default value is expensive.

Source

pub fn and_modify(self, f: impl FnOnce(&mut HeaderValues)) -> Self

Provides in-place mutable access to an occupied entry before any potential inserts with Entry::or_insert or Entry::or_insert_with.

Source

pub fn is_vacant(&self) -> bool

Predicate to determine if this is a VacantEntry

Source

pub fn is_occupied(&self) -> bool

Predicate to determine if this is an OccupiedEntry

Source

pub fn occupied(self) -> Option<OccupiedEntry<'a>>

Return the OccupiedEntry, if this entry is occupied

Source

pub fn vacant(self) -> Option<VacantEntry<'a>>

Return the VacantEntry, if this entry is vacant

Trait Implementations§

Source§

impl<'a> Debug for Entry<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Entry<'a>

§

impl<'a> RefUnwindSafe for Entry<'a>

§

impl<'a> Send for Entry<'a>

§

impl<'a> Sync for Entry<'a>

§

impl<'a> Unpin for Entry<'a>

§

impl<'a> UnsafeUnpin for Entry<'a>

§

impl<'a> !UnwindSafe for Entry<'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> 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, 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.