azure_core/request_options/
if_modified_since.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use crate::{
    date,
    headers::{self, Header},
};
use time::OffsetDateTime;

#[derive(Debug, Clone, Copy)]
pub struct IfModifiedSince(OffsetDateTime);

impl IfModifiedSince {
    pub fn new(time: OffsetDateTime) -> Self {
        Self(time)
    }
}

impl Header for IfModifiedSince {
    fn name(&self) -> headers::HeaderName {
        headers::IF_MODIFIED_SINCE
    }

    fn value(&self) -> headers::HeaderValue {
        date::to_rfc1123(&self.0).into()
    }
}

impl From<OffsetDateTime> for IfModifiedSince {
    fn from(time: OffsetDateTime) -> Self {
        Self::new(time)
    }
}