pub struct EntityTag<'t> {
pub weak: bool,
/* private fields */
}Expand description
An entity tag, defined in RFC 9110.
Fields§
§weak: boolWhether to have a weakness indicator.
Implementations§
Source§impl<'t> EntityTag<'t>
impl<'t> EntityTag<'t>
Sourcepub const unsafe fn new_unchecked(weak: bool, tag: Cow<'t, str>) -> Self
pub const unsafe fn new_unchecked(weak: bool, tag: Cow<'t, str>) -> Self
Construct a new EntityTag without checking.
§Safety
The caller must ensure tag is a valid unquoted entity-tag value, because this function skips all validation.
Sourcepub const fn get_tag_cow(&self) -> &Cow<'t, str>
pub const fn get_tag_cow(&self) -> &Cow<'t, str>
Get the tag. The double quotes are not included.
Source§impl<'t> EntityTag<'t>
impl<'t> EntityTag<'t>
Source§impl<'t> EntityTag<'t>
impl<'t> EntityTag<'t>
Sourcepub fn with_string<S: AsRef<str> + Into<String>>(
weak: bool,
tag: S,
) -> Result<EntityTag<'static>, EntityTagError>
pub fn with_string<S: AsRef<str> + Into<String>>( weak: bool, tag: S, ) -> Result<EntityTag<'static>, EntityTagError>
Construct a new EntityTag from an opaque tag, with or without surrounding double quotes.
Source§impl<'t> EntityTag<'t>
impl<'t> EntityTag<'t>
Sourcepub fn from_string<S: AsRef<str> + Into<String>>(
etag: S,
) -> Result<EntityTag<'static>, EntityTagError>
pub fn from_string<S: AsRef<str> + Into<String>>( etag: S, ) -> Result<EntityTag<'static>, EntityTagError>
Parse and construct a new EntityTag from a full ETag header value.
Sourcepub fn from_str<S: ?Sized + AsRef<str>>(
etag: &'t S,
) -> Result<Self, EntityTagError>
pub fn from_str<S: ?Sized + AsRef<str>>( etag: &'t S, ) -> Result<Self, EntityTagError>
Parse and construct a new EntityTag from a full ETag header value.
Sourcepub fn from_data<S: ?Sized + AsRef<[u8]>>(data: &S) -> EntityTag<'static>
pub fn from_data<S: ?Sized + AsRef<[u8]>>(data: &S) -> EntityTag<'static>
Construct a weak EntityTag from data with an XXH3-128 fingerprint.
Requires the weak-hasher feature.
Sourcepub fn from_data_strong<S: ?Sized + AsRef<[u8]>>(data: &S) -> EntityTag<'static>
pub fn from_data_strong<S: ?Sized + AsRef<[u8]>>(data: &S) -> EntityTag<'static>
Construct a strong EntityTag from data with a BLAKE3-256 digest.
Requires the strong-hasher feature.
Sourcepub fn from_file_meta(metadata: &Metadata) -> EntityTag<'static>
pub fn from_file_meta(metadata: &Metadata) -> EntityTag<'static>
Construct a weak EntityTag from file metadata with an XXH3-128 fingerprint.
Requires the std and weak-hasher features.
This method hashes the file length and modification time, not the file content.
If the modification time is not available, it hashes only the file length.
Sourcepub fn from_file_meta_strong(metadata: &Metadata) -> EntityTag<'static>
pub fn from_file_meta_strong(metadata: &Metadata) -> EntityTag<'static>
Construct a strong EntityTag from file metadata with a BLAKE3-256 digest.
Requires the std and strong-hasher features.
§Strong Validation
This method hashes the file length and modification time, not the file content.
If the modification time is not available, it hashes only the file length.
Only use this method if these metadata values change for every content change and distinguish all representations of the same resource.
Otherwise, use Self::from_data_strong with the bytes sent in the response.
Source§impl<'t> EntityTag<'t>
impl<'t> EntityTag<'t>
Sourcepub fn strong_eq(&self, other: &EntityTag<'_>) -> bool
pub fn strong_eq(&self, other: &EntityTag<'_>) -> bool
For strong comparison two entity-tags are equivalent if both are not weak and their opaque-tags match character-by-character.