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>
impl<'a> Entry<'a>
Sourcepub fn name(&self) -> HeaderName<'_>
pub fn name(&self) -> HeaderName<'_>
retrieve the HeaderName for this entry.
Sourcepub fn insert(self, values: impl Into<HeaderValues>) -> &'a mut HeaderValues
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.
Sourcepub fn append(self, values: impl Into<HeaderValues>) -> &'a mut HeaderValues
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.
Sourcepub fn or_insert_with<V: Into<HeaderValues>>(
self,
values: impl FnOnce() -> V,
) -> &'a mut HeaderValues
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.
Sourcepub fn or_insert(self, values: impl Into<HeaderValues>) -> &'a mut HeaderValues
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.
Sourcepub fn and_modify(self, f: impl FnOnce(&mut HeaderValues)) -> Self
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.
Sourcepub fn is_occupied(&self) -> bool
pub fn is_occupied(&self) -> bool
Predicate to determine if this is an OccupiedEntry
Sourcepub fn occupied(self) -> Option<OccupiedEntry<'a>>
pub fn occupied(self) -> Option<OccupiedEntry<'a>>
Return the OccupiedEntry, if this entry is occupied
Sourcepub fn vacant(self) -> Option<VacantEntry<'a>>
pub fn vacant(self) -> Option<VacantEntry<'a>>
Return the VacantEntry, if this entry is vacant