pub struct Expires { /* private fields */ }
Expand description
HTTP Expires
header
§Specifications
§Examples
use http_types_rs::Response;
use http_types_rs::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);
res.insert_header(&expires, &expires);
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§
Source§impl Expires
impl Expires
Sourcepub fn new_at(instant: SystemTime) -> Self
pub fn new_at(instant: SystemTime) -> Self
Create a new instance of Expires
from secs.
Sourcepub fn expiration(&self) -> SystemTime
pub fn expiration(&self) -> SystemTime
Get the expiration time.
Trait Implementations§
Source§impl Header for Expires
impl Header for Expires
Source§fn header_name(&self) -> HeaderName
fn header_name(&self) -> HeaderName
Access the header’s name.
Source§fn header_value(&self) -> HeaderValue
fn header_value(&self) -> HeaderValue
Access the header’s value.
Source§impl Ord for Expires
impl Ord for Expires
Source§impl PartialOrd for Expires
impl PartialOrd for Expires
impl Eq for Expires
impl StructuralPartialEq for Expires
Auto Trait Implementations§
impl Freeze for Expires
impl RefUnwindSafe for Expires
impl Send for Expires
impl Sync for Expires
impl Unpin for Expires
impl UnwindSafe for Expires
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
Source§impl<T> ToHeaderValues for Twhere
T: Header,
impl<T> ToHeaderValues for Twhere
T: Header,
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<<T as ToHeaderValues>::Iter, Error>
fn to_header_values(&self) -> Result<<T as ToHeaderValues>::Iter, Error>
Converts this object to an iterator of resolved
HeaderValues
.