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
impl Date
impl Date
pub fn new(at: SystemTime) -> Date
pub fn new(at: SystemTime) -> Date
Create a new instance.
pub fn from_headers(headers: impl AsRef<Headers>) -> Result<Option<Date>, Error>
pub fn from_headers(headers: impl AsRef<Headers>) -> Result<Option<Date>, Error>
Create a new instance from headers.
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 From<SystemTime> for Date
impl From<SystemTime> for Date
fn from(time: SystemTime) -> Date
fn from(time: SystemTime) -> Date
Converts to this type from the input type.
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more