diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /third_party/rust/headers/src/common/last_modified.rs | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/headers/src/common/last_modified.rs')
-rw-r--r-- | third_party/rust/headers/src/common/last_modified.rs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/third_party/rust/headers/src/common/last_modified.rs b/third_party/rust/headers/src/common/last_modified.rs new file mode 100644 index 0000000000..c8f47dabdf --- /dev/null +++ b/third_party/rust/headers/src/common/last_modified.rs @@ -0,0 +1,51 @@ +use std::time::SystemTime; +use util::HttpDate; + +/// `Last-Modified` header, defined in +/// [RFC7232](http://tools.ietf.org/html/rfc7232#section-2.2) +/// +/// The `Last-Modified` header field in a response provides a timestamp +/// indicating the date and time at which the origin server believes the +/// selected representation was last modified, as determined at the +/// conclusion of handling the request. +/// +/// # ABNF +/// +/// ```text +/// Expires = HTTP-date +/// ``` +/// +/// # Example values +/// +/// * `Sat, 29 Oct 1994 19:43:31 GMT` +/// +/// # Example +/// +/// ``` +/// # extern crate headers; +/// use headers::LastModified; +/// use std::time::{Duration, SystemTime}; +/// +/// let modified = LastModified::from( +/// SystemTime::now() - Duration::from_secs(60 * 60 * 24) +/// ); +/// ``` +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct LastModified(pub(super) HttpDate); + +derive_header! { + LastModified(_), + name: LAST_MODIFIED +} + +impl From<SystemTime> for LastModified { + fn from(time: SystemTime) -> LastModified { + LastModified(time.into()) + } +} + +impl From<LastModified> for SystemTime { + fn from(date: LastModified) -> SystemTime { + date.0.into() + } +} |