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
Auto Trait Implementations§
impl Freeze for Date
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