Debian Codegraph @

third_party/rust/headers/src/common/last_modified.rs

raw
1 use std::time::SystemTime;
2 use util::HttpDate;
3
4 /// `Last-Modified` header, defined in
5 /// [RFC7232](http://tools.ietf.org/html/rfc7232#section-2.2)
6 ///
7 /// The `Last-Modified` header field in a response provides a timestamp
8 /// indicating the date and time at which the origin server believes the
9 /// selected representation was last modified, as determined at the
10 /// conclusion of handling the request.
11 ///
12 /// # ABNF
13 ///
14 /// ```text
15 /// Expires = HTTP-date
16 /// ```
17 ///
18 /// # Example values
19 ///
20 /// * `Sat, 29 Oct 1994 19:43:31 GMT`
21 ///
22 /// # Example
23 ///
24 /// ```
25 /// # extern crate headers;
26 /// use headers::LastModified;
27 /// use std::time::{Duration, SystemTime};
28 ///
29 /// let modified = LastModified::from(
30 /// SystemTime::now() - Duration::from_secs(60 * 60 * 24)
31 /// );
32 /// ```
33 #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
34 pub struct LastModified(pub(super) HttpDate);
35
36 derive_header! {
37 LastModified(_),
38 name: LAST_MODIFIED
39 }
40
41 impl From<SystemTime> for LastModified {
42 fn from(time: SystemTime) -> LastModified {
43 LastModified(time.into())
44 }
45 }
46
47 impl From<LastModified> for SystemTime {
48 fn from(date: LastModified) -> SystemTime {
49 date.0.into()
50 }
51 }