pub struct Date { /* private fields */ }
Expand description
The date and time at which the message originated.
§Specifications
§Examples
use http_types_rs::Response;
use http_types_rs::other::Date;
use std::time::{Duration, SystemTime};
let now = SystemTime::now();
let date = Date::new(now);
let mut res = Response::new(200);
res.insert_header(&date, &date);
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§
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 Header for Date
impl Header for Date
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 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
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
.