diff options
Diffstat (limited to 'src/encoding/headers.rs')
-rw-r--r-- | src/encoding/headers.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/encoding/headers.rs b/src/encoding/headers.rs index afcfef1..e880739 100644 --- a/src/encoding/headers.rs +++ b/src/encoding/headers.rs @@ -166,7 +166,17 @@ impl Display for Contact { } impl FromStr for Contact { type Err = anyhow::Error; - fn from_str(_s: &str) -> Result<Self, Self::Err> { - todo!() + fn from_str(s: &str) -> Result<Self, Self::Err> { + let (display_name, rest) = s.split_once("<").ok_or(anyhow!("malformed contact"))?; + let (uri, params) = rest.split_once(">;").ok_or(anyhow!("malformed contact"))?; + Ok(Self { + display_name: if display_name.is_empty() { + None + } else { + Some(display_name.to_string()) + }, + params: params.to_string(), + uri: Uri::from_str(uri)?, + }) } } |