diff options
author | metamuffin <metamuffin@disroot.org> | 2024-07-06 15:43:45 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-07-06 15:43:45 +0200 |
commit | 7177367ae41a5e2d6ed401f60ee1455812dd8ffb (patch) | |
tree | 75c89835d03e1a1ccd4e8c930c95310f757b2b3a /src/encoding/headers.rs | |
parent | 5dd0fafce20ed37fdc97dc96539391ebdebffaff (diff) | |
download | sip-rs-7177367ae41a5e2d6ed401f60ee1455812dd8ffb.tar sip-rs-7177367ae41a5e2d6ed401f60ee1455812dd8ffb.tar.bz2 sip-rs-7177367ae41a5e2d6ed401f60ee1455812dd8ffb.tar.zst |
phone is ringing
Diffstat (limited to 'src/encoding/headers.rs')
-rw-r--r-- | src/encoding/headers.rs | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/src/encoding/headers.rs b/src/encoding/headers.rs index 9e785f0..afcfef1 100644 --- a/src/encoding/headers.rs +++ b/src/encoding/headers.rs @@ -1,4 +1,4 @@ -use super::{headermap::HeaderMap, method::Method}; +use super::{headermap::HeaderMap, method::Method, uri::Uri}; use anyhow::{anyhow, bail, Result}; use std::{fmt::Display, str::FromStr}; @@ -31,7 +31,6 @@ header!("Content-Length", struct ContentLength(usize)); header!("Content-Type", struct ContentType(String)); header!("Call-ID", struct CallID(String)); header!("Via", struct Via(String)); -header!("Contact", struct Contact(String)); header!("Max-Forwards", struct MaxForwards(usize)); header!("From", struct From(String)); header!("To", struct To(String)); @@ -100,7 +99,7 @@ impl FromStr for WWWAuthenticate { } } -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct Authorization { pub username: String, pub realm: String, @@ -140,3 +139,34 @@ pub fn unquote(v: &str) -> Result<String> { .ok_or(anyhow!("end quote missing"))? .to_string()) } + +#[derive(Debug)] +pub struct Contact { + pub display_name: Option<String>, + pub uri: Uri, + pub params: String, +} + +impl Header for Contact { + const NAME: &'static str = "Contact"; +} +impl Display for Contact { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let Self { + display_name, + uri, + params, + } = self; + if let Some(display_name) = display_name { + write!(f, "{display_name} <{uri}>{params}") + } else { + write!(f, "<{uri}>{params}") + } + } +} +impl FromStr for Contact { + type Err = anyhow::Error; + fn from_str(_s: &str) -> Result<Self, Self::Err> { + todo!() + } +} |