aboutsummaryrefslogtreecommitdiff
path: root/sip/src/transport
diff options
context:
space:
mode:
Diffstat (limited to 'sip/src/transport')
-rw-r--r--sip/src/transport/mod.rs21
1 files changed, 21 insertions, 0 deletions
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,
+ }
+ }
+}