1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use azure_core::AppendToUrlQuery;
use std::time::Duration;

#[derive(Debug, Clone)]
pub struct MessageTTL(Duration);

impl MessageTTL {
    pub fn new(message_ttl: impl Into<Duration>) -> Self {
        Self(message_ttl.into())
    }
}

impl AppendToUrlQuery for MessageTTL {
    fn append_to_url_query(&self, url: &mut url::Url) {
        url.query_pairs_mut()
            .append_pair("messagettl", &self.0.as_secs().to_string());
    }
}

impl From<Duration> for MessageTTL {
    fn from(message_ttl: Duration) -> Self {
        Self(message_ttl)
    }
}