Struct http_types::cache::Expires [−][src]
pub struct Expires { /* fields omitted */ }HTTP Expires header
Specifications
Examples
use http_types::Response; use http_types::cache::Expires; use std::time::{SystemTime, Duration}; let time = SystemTime::now() + Duration::from_secs(5 * 60); let expires = Expires::new_at(time); let mut res = Response::new(200); expires.apply(&mut res); let expires = Expires::from_headers(res)?.unwrap(); // HTTP dates only have second-precision. let elapsed = time.duration_since(expires.expiration())?; assert_eq!(elapsed.as_secs(), 0);
Implementations
impl Expires[src]
impl Expires[src]pub fn new(dur: Duration) -> Self[src]
Create a new instance of Expires.
pub fn new_at(instant: SystemTime) -> Self[src]
Create a new instance of Expires from secs.
pub fn expiration(&self) -> SystemTime[src]
Get the expiration time.
pub fn from_headers(headers: impl AsRef<Headers>) -> Result<Option<Self>>[src]
Create an instance of Expires from a Headers instance.
pub fn apply(&self, headers: impl AsMut<Headers>)[src]
Insert a HeaderName + HeaderValue pair into a Headers instance.
pub fn name(&self) -> HeaderName[src]
Get the HeaderName.
pub fn value(&self) -> HeaderValue[src]
Get the HeaderValue.
Trait Implementations
impl PartialOrd<Expires> for Expires[src]
impl PartialOrd<Expires> for Expires[src]impl StructuralEq for Expires[src]
impl StructuralEq for Expires[src]impl StructuralPartialEq for Expires[src]
impl StructuralPartialEq for Expires[src]impl ToHeaderValues for Expires[src]
impl ToHeaderValues for Expires[src]type Iter = IntoIter<HeaderValue>
Returned iterator over header values which this type may correspond to.
fn to_header_values(&self) -> Result<Self::Iter>[src]
Auto Trait Implementations
impl RefUnwindSafe for Expires
impl RefUnwindSafe for Expiresimpl UnwindSafe for Expires
impl UnwindSafe for Expires