diff options
Diffstat (limited to 'sip/src')
-rw-r--r-- | sip/src/encoding/headers.rs | 2 | ||||
-rw-r--r-- | sip/src/transport/mod.rs | 21 |
2 files changed, 22 insertions, 1 deletions
diff --git a/sip/src/encoding/headers.rs b/sip/src/encoding/headers.rs index e880739..30587c7 100644 --- a/sip/src/encoding/headers.rs +++ b/sip/src/encoding/headers.rs @@ -140,7 +140,7 @@ pub fn unquote(v: &str) -> Result<String> { .to_string()) } -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct Contact { pub display_name: Option<String>, pub uri: Uri, diff --git a/sip/src/transport/mod.rs b/sip/src/transport/mod.rs index b4c512b..b9cdaeb 100644 --- a/sip/src/transport/mod.rs +++ b/sip/src/transport/mod.rs @@ -1,5 +1,7 @@ use crate::encoding::Message; use anyhow::Result; +use tcp::TcpTransport; +use udp::UdpTransport; pub mod tcp; pub mod udp; @@ -9,3 +11,22 @@ pub trait Transport { async fn recv(&self) -> Result<Message>; async fn send(&self, message: Message) -> Result<()>; } + +pub enum InetTransport { + Udp(UdpTransport), + Tcp(TcpTransport), +} +impl Transport for InetTransport { + async fn recv(&self) -> Result<Message> { + match self { + InetTransport::Udp(t) => t.recv().await, + InetTransport::Tcp(t) => t.recv().await, + } + } + async fn send(&self, message: Message) -> Result<()> { + match self { + InetTransport::Udp(t) => t.send(message).await, + InetTransport::Tcp(t) => t.send(message).await, + } + } +} |