Struct http_types_rs::other::Date
source · 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
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 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> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> ToHeaderValues for Twhere
T: Header,
impl<T> ToHeaderValues for Twhere
T: Header,
§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
.