Skip to main content

IfRange

Enum IfRange 

Source
pub enum IfRange<'a> {
    Date(HttpDate),
    Tag(EntityTag<'a>),
}
Expand description

A parsed If-Range value.

Variants§

§

Date(HttpDate)

An HTTP-date.

§

Tag(EntityTag<'a>)

An entity tag.

Implementations§

Source§

impl IfRange<'_>

Source

pub fn matches( &self, current_tag: Option<&EntityTag<'_>>, last_modified: Option<HttpDate>, ) -> bool

Whether the condition holds, so the ranges may be served (RFC 9110 section 13.1.5): a tag matches by strong comparison (a weak tag never matches); a date matches when it equals last_modified exactly. When it does not hold, send the whole representation.

§Examples
use parse_net::{range::parse_if_range, EntityTag};

let current = EntityTag::strong(b"v1")?;
assert!(parse_if_range(b"\"v1\"")?.matches(Some(&current), None));
assert!(!parse_if_range(b"W/\"v1\"")?.matches(Some(&current), None));

Trait Implementations§

Source§

impl<'a> Clone for IfRange<'a>

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<'a> Copy for IfRange<'a>

Source§

impl<'a> Debug for IfRange<'a>

Source§

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

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

impl<'a> Eq for IfRange<'a>

Source§

impl<'a> Hash for IfRange<'a>

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<'a> PartialEq for IfRange<'a>

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<'a> StructuralPartialEq for IfRange<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for IfRange<'a>

§

impl<'a> RefUnwindSafe for IfRange<'a>

§

impl<'a> Send for IfRange<'a>

§

impl<'a> Sync for IfRange<'a>

§

impl<'a> Unpin for IfRange<'a>

§

impl<'a> UnsafeUnpin for IfRange<'a>

§

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