Struct http_types::other::Date
source · pub struct Date { /* private fields */ }
Expand description
The date and time at which the message originated.
Specifications
Examples
use http_types::Response;
use http_types::other::Date;
use std::time::{Duration, SystemTime};
let now = SystemTime::now();
let date = Date::new(now);
let mut res = Response::new(200);
date.apply(&mut res);
let date = Date::from_headers(res)?.unwrap();
// Validate we're within 1 second accurate of the system time.
assert!(now.duration_since(date.into())? <= Duration::from_secs(1));
Implementations§
source§impl Date
impl Date
sourcepub fn new(at: SystemTime) -> Self
pub fn new(at: SystemTime) -> Self
Create a new instance.
sourcepub fn from_headers(headers: impl AsRef<Headers>) -> Result<Option<Self>>
pub fn from_headers(headers: impl AsRef<Headers>) -> Result<Option<Self>>
Create a new instance from headers.
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 From<Date> for SystemTime
impl From<Date> for SystemTime
source§impl From<SystemTime> for Date
impl From<SystemTime> for Date
source§fn from(time: SystemTime) -> Self
fn from(time: SystemTime) -> Self
Converts to this type from the input type.
source§impl PartialEq<SystemTime> for Date
impl PartialEq<SystemTime> for Date
source§fn eq(&self, other: &SystemTime) -> bool
fn eq(&self, other: &SystemTime) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.Auto Trait Implementations§
impl RefUnwindSafe for Date
impl Send for Date
impl Sync for Date
impl Unpin for Date
impl UnwindSafe for Date
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