ftth_rsip/common/uri/param/expires.rs
1use rsip_derives::{IntoParam, NewType};
2
3/// Simple NewType around String. Intended to be used for the `expires` parameter found in the
4/// `Contact` header.
5//TODO: add typed + default
6#[derive(NewType, IntoParam, Debug, PartialEq, Eq, Clone)]
7pub struct Expires(String);
8
9impl Expires {
10 pub fn seconds(&self) -> Result<u32, crate::Error> {
11 Ok(self.value().parse::<u32>()?)
12 }
13}
14
15#[cfg(feature = "test-utils")]
16impl testing_utils::Randomize for Expires {
17 fn random() -> Self {
18 Self(testing_utils::rand_num_from(0..10000).to_string())
19 }
20}