Debian Codegraph @

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

raw
1 use std::time::SystemTime;
2 use util::HttpDate;
3
4 /// `Expires` header, defined in [RFC7234](http://tools.ietf.org/html/rfc7234#section-5.3)
5 ///
6 /// The `Expires` header field gives the date/time after which the
7 /// response is considered stale.
8 ///
9 /// The presence of an Expires field does not imply that the original
10 /// resource will change or cease to exist at, before, or after that
11 /// time.
12 ///
13 /// # ABNF
14 ///
15 /// ```text
16 /// Expires = HTTP-date
17 /// ```
18 ///
19 /// # Example values
20 /// * `Thu, 01 Dec 1994 16:00:00 GMT`
21 ///
22 /// # Example
23 ///
24 /// ```
25 /// # extern crate headers;
26 /// use headers::Expires;
27 /// use std::time::{SystemTime, Duration};
28 ///
29 /// let time = SystemTime::now() + Duration::from_secs(60 * 60 * 24);
30 /// let expires = Expires::from(time);
31 /// ```
32 #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
33 pub struct Expires(HttpDate);
34
35 derive_header! {
36 Expires(_),
37 name: EXPIRES
38 }
39
40 impl From<SystemTime> for Expires {
41 fn from(time: SystemTime) -> Expires {
42 Expires(time.into())
43 }
44 }
45
46 impl From<Expires> for SystemTime {
47 fn from(date: Expires) -> SystemTime {
48 date.0.into()
49 }
50 }