diff options
author | metamuffin <metamuffin@disroot.org> | 2025-02-23 12:14:27 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-02-23 12:14:27 +0100 |
commit | beab67b2e38808f91ecd390190d527fc7db5499d (patch) | |
tree | f74071b32c0971a7f3354901e164ce7b47c95f88 /sip/src | |
parent | d07dcedf8f9601fda14f79ebfbcf858d3794c16c (diff) | |
download | sip-rs-beab67b2e38808f91ecd390190d527fc7db5499d.tar sip-rs-beab67b2e38808f91ecd390190d527fc7db5499d.tar.bz2 sip-rs-beab67b2e38808f91ecd390190d527fc7db5499d.tar.zst |
call receive tool
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, + } + } +} |