pub(crate) struct EntityTag<T = HeaderValue>(T);
Expand description
An entity tag, defined in RFC7232
An entity tag consists of a string enclosed by two literal double quotes.
Preceding the first double quote is an optional weakness indicator,
which always looks like W/
. Examples for valid tags are "xyzzy"
and W/"xyzzy"
.
§ABNF
entity-tag = [ weak ] opaque-tag
weak = %x57.2F ; "W/", case-sensitive
opaque-tag = DQUOTE *etagc DQUOTE
etagc = %x21 / %x23-7E / obs-text
; VCHAR except double quotes, plus obs-text
§Comparison
To check if two entity tags are equivalent in an application always use the strong_eq
or
weak_eq
methods based on the context of the Tag. Only use ==
to check if two tags are
identical.
The example below shows the results for a set of entity-tag pairs and both the weak and strong comparison function results:
ETag 1 | ETag 2 | Strong Comparison | Weak Comparison |
---|---|---|---|
W/"1" | W/"1" | no match | match |
W/"1" | W/"2" | no match | no match |
W/"1" | "1" | no match | match |
"1" | "1" | match | match |
Tuple Fields§
§0: T
Implementations§
source§impl<T: AsRef<[u8]>> EntityTag<T>
impl<T: AsRef<[u8]>> EntityTag<T>
sourcepub(crate) fn strong_eq<R>(&self, other: &EntityTag<R>) -> bool
pub(crate) fn strong_eq<R>(&self, other: &EntityTag<R>) -> bool
For strong comparison two entity-tags are equivalent if both are not weak and their opaque-tags match character-by-character.
sourcepub(crate) fn weak_eq<R>(&self, other: &EntityTag<R>) -> bool
pub(crate) fn weak_eq<R>(&self, other: &EntityTag<R>) -> bool
For weak comparison two entity-tags are equivalent if their opaque-tags match character-by-character, regardless of either or both being tagged as “weak”.
pub(crate) fn parse(src: T) -> Option<Self>
source§impl EntityTag
impl EntityTag
pub(crate) fn from_owned(val: HeaderValue) -> Option<EntityTag>
pub(crate) fn from_val(val: &HeaderValue) -> Option<EntityTag>
Trait Implementations§
source§impl<'a> From<&'a EntityTag> for HeaderValue
impl<'a> From<&'a EntityTag> for HeaderValue
source§fn from(tag: &'a EntityTag) -> HeaderValue
fn from(tag: &'a EntityTag) -> HeaderValue
source§impl From<EntityTag> for HeaderValue
impl From<EntityTag> for HeaderValue
source§fn from(tag: EntityTag) -> HeaderValue
fn from(tag: EntityTag) -> HeaderValue
source§impl TryFromValues for EntityTag
impl TryFromValues for EntityTag
source§fn try_from_values<'i, I>(values: &mut I) -> Result<Self, Error>where
I: Iterator<Item = &'i HeaderValue>,
fn try_from_values<'i, I>(values: &mut I) -> Result<Self, Error>where
I: Iterator<Item = &'i HeaderValue>,
Self
.impl<T: Eq> Eq for EntityTag<T>
impl<T> StructuralPartialEq for EntityTag<T>
Auto Trait Implementations§
impl<T> Freeze for EntityTag<T>where
T: Freeze,
impl<T> RefUnwindSafe for EntityTag<T>where
T: RefUnwindSafe,
impl<T> Send for EntityTag<T>where
T: Send,
impl<T> Sync for EntityTag<T>where
T: Sync,
impl<T> Unpin for EntityTag<T>where
T: Unpin,
impl<T> UnwindSafe for EntityTag<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)