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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use crate::{
common::{
uri::{param, Param},
Uri,
},
headers::untyped::ToTypedHeader,
Error,
};
use rsip_derives::{ToTypedHeader, UntypedHeader};
#[derive(ToTypedHeader, UntypedHeader, Debug, PartialEq, Eq, Clone)]
pub struct Contact(String);
impl Contact {
pub fn display_name(&self) -> Result<Option<String>, Error> {
self.typed().map(|s| s.display_name)
}
pub fn uri(&self) -> Result<Uri, Error> {
Ok(self.typed()?.uri)
}
pub fn params(&self) -> Result<Vec<Param>, Error> {
Ok(self.typed()?.params)
}
pub fn expires(&self) -> Result<Option<param::Expires>, Error> {
self.typed().map(|s| s.expires().cloned())
}
pub fn with_uri(mut self, uri: Uri) -> Result<Self, Error> {
let mut typed = self.typed()?;
typed.uri = uri;
self.0 = typed.into();
Ok(self)
}
pub fn mut_uri(&mut self, uri: Uri) -> Result<&mut Self, Error> {
let mut typed = self.typed()?;
typed.uri = uri;
self.0 = typed.into();
Ok(self)
}
pub fn with_params(mut self, params: Vec<Param>) -> Result<Self, Error> {
let mut typed = self.typed()?;
typed.params = params;
self.0 = typed.into();
Ok(self)
}
pub fn mut_params(&mut self, params: Vec<Param>) -> Result<&mut Self, Error> {
let mut typed = self.typed()?;
typed.params = params;
self.0 = typed.into();
Ok(self)
}
}