azure_core/request_options/
if_modified_since_condition.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
use crate::{
    date,
    headers::{self, Header, HeaderName},
};
use time::OffsetDateTime;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum IfModifiedSinceCondition {
    Modified(OffsetDateTime),
    Unmodified(OffsetDateTime),
}

impl Header for IfModifiedSinceCondition {
    fn name(&self) -> HeaderName {
        match self {
            IfModifiedSinceCondition::Modified(_) => headers::IF_MODIFIED_SINCE,
            IfModifiedSinceCondition::Unmodified(_) => headers::IF_UNMODIFIED_SINCE,
        }
    }

    fn value(&self) -> headers::HeaderValue {
        match self {
            IfModifiedSinceCondition::Modified(date)
            | IfModifiedSinceCondition::Unmodified(date) => date::to_rfc1123(date),
        }
        .into()
    }
}