pub struct IfUnmodifiedSince { /* private fields */ }
Expand description
Apply the HTTP method if the entity has not been modified after the given date.
§Specifications
§Examples
use http_types::Response;
use http_types::conditional::IfUnmodifiedSince;
use std::time::{SystemTime, Duration};
let time = SystemTime::now() + Duration::from_secs(5 * 60);
let expires = IfUnmodifiedSince::new(time);
let mut res = Response::new(200);
expires.apply(&mut res);
let expires = IfUnmodifiedSince::from_headers(res)?.unwrap();
// HTTP dates only have second-precision.
let elapsed = time.duration_since(expires.modified())?;
assert_eq!(elapsed.as_secs(), 0);
Implementations§
Source§impl IfUnmodifiedSince
impl IfUnmodifiedSince
Sourcepub fn new(instant: SystemTime) -> Self
pub fn new(instant: SystemTime) -> Self
Create a new instance of IfUnmodifiedSince
.
Sourcepub fn modified(&self) -> SystemTime
pub fn modified(&self) -> SystemTime
Returns the last modification time listed.
Sourcepub fn from_headers(headers: impl AsRef<Headers>) -> Result<Option<Self>>
pub fn from_headers(headers: impl AsRef<Headers>) -> Result<Option<Self>>
Create an instance of IfUnmodifiedSince
from a Headers
instance.
Sourcepub fn apply(&self, headers: impl AsMut<Headers>)
pub fn apply(&self, headers: impl AsMut<Headers>)
Insert a HeaderName
+ HeaderValue
pair into a Headers
instance.
Sourcepub fn name(&self) -> HeaderName
pub fn name(&self) -> HeaderName
Get the HeaderName
.
Sourcepub fn value(&self) -> HeaderValue
pub fn value(&self) -> HeaderValue
Get the HeaderValue
.
Trait Implementations§
Source§impl Debug for IfUnmodifiedSince
impl Debug for IfUnmodifiedSince
Source§impl Ord for IfUnmodifiedSince
impl Ord for IfUnmodifiedSince
Source§fn cmp(&self, other: &IfUnmodifiedSince) -> Ordering
fn cmp(&self, other: &IfUnmodifiedSince) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for IfUnmodifiedSince
impl PartialEq for IfUnmodifiedSince
Source§impl PartialOrd for IfUnmodifiedSince
impl PartialOrd for IfUnmodifiedSince
Source§impl ToHeaderValues for IfUnmodifiedSince
impl ToHeaderValues for IfUnmodifiedSince
Source§type Iter = IntoIter<HeaderValue>
type Iter = IntoIter<HeaderValue>
Returned iterator over header values which this type may correspond to.
Source§fn to_header_values(&self) -> Result<Self::Iter>
fn to_header_values(&self) -> Result<Self::Iter>
Converts this object to an iterator of resolved
HeaderValues
.impl Eq for IfUnmodifiedSince
impl StructuralPartialEq for IfUnmodifiedSince
Auto Trait Implementations§
impl Freeze for IfUnmodifiedSince
impl RefUnwindSafe for IfUnmodifiedSince
impl Send for IfUnmodifiedSince
impl Sync for IfUnmodifiedSince
impl Unpin for IfUnmodifiedSince
impl UnwindSafe for IfUnmodifiedSince
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
Mutably borrows from an owned value. Read more