Skip to main content

EntityTag

Struct EntityTag 

Source
pub struct EntityTag<'t> {
    pub weak: bool,
    /* private fields */
}
Expand description

An entity tag, defined in RFC 9110.

Fields§

§weak: bool

Whether to have a weakness indicator.

Implementations§

Source§

impl<'t> EntityTag<'t>

Source

pub const HEADER_NAME: &'static str = "ETag"

ETag

Source§

impl<'t> EntityTag<'t>

Source

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.

Source

pub const fn get_tag_cow(&self) -> &Cow<'t, str>

Get the tag. The double quotes are not included.

Source§

impl<'t> EntityTag<'t>

Source

pub unsafe fn with_string_unchecked<S: Into<String>>( weak: bool, tag: S, ) -> EntityTag<'static>

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.

Source

pub unsafe fn with_str_unchecked<S: ?Sized + AsRef<str>>( weak: bool, tag: &'t S, ) -> 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.

Source§

impl<'t> EntityTag<'t>

Source

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

pub fn with_str<S: ?Sized + AsRef<str>>( weak: bool, tag: &'t S, ) -> Result<Self, EntityTagError>

Construct a new EntityTag from an opaque tag, with or without surrounding double quotes.

Source§

impl<'t> EntityTag<'t>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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>

Source

pub fn get_tag(&self) -> &str

Get the tag. The double quotes are not included.

Source

pub fn into_tag(self) -> Cow<'t, str>

Into the tag. The double quotes are not included.

Source

pub fn into_owned(self) -> EntityTag<'static>

Extracts the owned data.

Source§

impl<'t> EntityTag<'t>

Source

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.

Source

pub fn weak_eq(&self, other: &EntityTag<'_>) -> 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”.

Source

pub fn strong_ne(&self, other: &EntityTag<'_>) -> bool

The inverse of strong_eq.

Source

pub fn weak_ne(&self, other: &EntityTag<'_>) -> bool

The inverse of weak_eq.

Trait Implementations§

Source§

impl<'t> Clone for EntityTag<'t>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'t> Debug for EntityTag<'t>

Source§

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

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

impl<'t> Display for EntityTag<'t>

Source§

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

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

impl<'t> Eq for EntityTag<'t>

Source§

impl FromStr for EntityTag<'static>

Source§

type Err = EntityTagError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<'t> Hash for EntityTag<'t>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'t> PartialEq for EntityTag<'t>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<'t> StructuralPartialEq for EntityTag<'t>

Auto Trait Implementations§

§

impl<'t> Freeze for EntityTag<'t>

§

impl<'t> RefUnwindSafe for EntityTag<'t>

§

impl<'t> Send for EntityTag<'t>

§

impl<'t> Sync for EntityTag<'t>

§

impl<'t> Unpin for EntityTag<'t>

§

impl<'t> UnsafeUnpin for EntityTag<'t>

§

impl<'t> UnwindSafe for EntityTag<'t>

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.