azure_core/request_options/
lease_duration.rs

1use crate::headers::{self, Header};
2use std::time::Duration;
3
4#[derive(Debug, Clone)]
5pub enum LeaseDuration {
6    Infinite,
7    Seconds(u8),
8}
9
10impl Header for LeaseDuration {
11    fn name(&self) -> headers::HeaderName {
12        headers::LEASE_DURATION
13    }
14
15    fn value(&self) -> headers::HeaderValue {
16        match self {
17            LeaseDuration::Infinite => "-1".to_owned(),
18            LeaseDuration::Seconds(seconds) => {
19                format!("{seconds}")
20            }
21        }
22        .into()
23    }
24}
25
26impl From<Duration> for LeaseDuration {
27    fn from(d: Duration) -> Self {
28        LeaseDuration::Seconds(d.as_secs() as u8)
29    }
30}