Struct sfo_http::http_server::http::conditional::LastModified
pub struct LastModified { /* private fields */ }Expand description
The last modification date of a resource.
Specifications
Examples
use http_types::Response;
use http_types::conditional::LastModified;
use std::time::{SystemTime, Duration};
let time = SystemTime::now() + Duration::from_secs(5 * 60);
let last_modified = LastModified::new(time);
let mut res = Response::new(200);
last_modified.apply(&mut res);
let last_modified = LastModified::from_headers(res)?.unwrap();
// HTTP dates only have second-precision.
let elapsed = time.duration_since(last_modified.modified())?;
assert_eq!(elapsed.as_secs(), 0);Implementations§
§impl LastModified
impl LastModified
pub fn new(instant: SystemTime) -> LastModified
pub fn new(instant: SystemTime) -> LastModified
Create a new instance of LastModified.
pub fn modified(&self) -> SystemTime
pub fn modified(&self) -> SystemTime
Returns the last modification time listed.
pub fn from_headers(
headers: impl AsRef<Headers>
) -> Result<Option<LastModified>, Error>
pub fn from_headers( headers: impl AsRef<Headers> ) -> Result<Option<LastModified>, Error>
Create an instance of LastModified from a Headers instance.
pub fn apply(&self, headers: impl AsMut<Headers>)
pub fn apply(&self, headers: impl AsMut<Headers>)
Insert a HeaderName + HeaderValue pair into a Headers instance.
pub fn name(&self) -> HeaderName
pub fn name(&self) -> HeaderName
Get the HeaderName.
pub fn value(&self) -> HeaderValue
pub fn value(&self) -> HeaderValue
Get the HeaderValue.
Trait Implementations§
§impl Debug for LastModified
impl Debug for LastModified
§impl Ord for LastModified
impl Ord for LastModified
§impl PartialEq<LastModified> for LastModified
impl PartialEq<LastModified> for LastModified
§fn eq(&self, other: &LastModified) -> bool
fn eq(&self, other: &LastModified) -> bool
This method tests for
self and other values to be equal, and is used
by ==.§impl PartialOrd<LastModified> for LastModified
impl PartialOrd<LastModified> for LastModified
§fn partial_cmp(&self, other: &LastModified) -> Option<Ordering>
fn partial_cmp(&self, other: &LastModified) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read more§impl ToHeaderValues for LastModified
impl ToHeaderValues for LastModified
§type Iter = IntoIter<HeaderValue>
type Iter = IntoIter<HeaderValue>
Returned iterator over header values which this type may correspond to.
§fn to_header_values(
&self
) -> Result<<LastModified as ToHeaderValues>::Iter, Error>
fn to_header_values( &self ) -> Result<<LastModified as ToHeaderValues>::Iter, Error>
Converts this object to an iterator of resolved
HeaderValues.impl Eq for LastModified
impl StructuralEq for LastModified
impl StructuralPartialEq for LastModified
Auto Trait Implementations§
impl RefUnwindSafe for LastModified
impl Send for LastModified
impl Sync for LastModified
impl Unpin for LastModified
impl UnwindSafe for LastModified
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