rsip/headers/untyped/
min_expires.rs

1use crate::Error;
2use rsip_derives::UntypedHeader;
3
4/// The `Min-Expires` header in its [untyped](super) form.
5#[derive(UntypedHeader, Debug, PartialEq, Eq, Clone)]
6pub struct MinExpires(String);
7
8impl MinExpires {
9    pub fn seconds(&self) -> Result<u32, crate::Error> {
10        use crate::headers::untyped::UntypedHeader;
11
12        Ok(self.value().parse::<u32>()?)
13    }
14}
15
16impl From<u32> for MinExpires {
17    fn from(from: u32) -> Self {
18        Self(from.to_string())
19    }
20}
21
22impl std::convert::TryFrom<MinExpires> for u32 {
23    type Error = Error;
24
25    fn try_from(from: MinExpires) -> Result<Self, Self::Error> {
26        from.seconds()
27    }
28}