From 9498c45d1291c0b2343339bad624d0dc0ca0a934 Mon Sep 17 00:00:00 2001 From: Lizzy Fleckenstein Date: Wed, 15 Feb 2023 22:04:42 +0100 Subject: Use Cow for Pkt --- src/send.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/send.rs') diff --git a/src/send.rs b/src/send.rs index e0c2fa3..a3a7f03 100644 --- a/src/send.rs +++ b/src/send.rs @@ -6,13 +6,13 @@ use tokio::sync::watch; pub type AckResult = io::Result>>; impl RudpSender { - pub async fn send(&self, pkt: Pkt<&[u8]>) -> AckResult { + pub async fn send(&self, pkt: Pkt<'_>) -> AckResult { self.share.send(PktType::Orig, pkt).await // TODO: splits } } impl RudpShare { - pub async fn send(&self, tp: PktType, pkt: Pkt<&[u8]>) -> AckResult { + pub async fn send(&self, tp: PktType, pkt: Pkt<'_>) -> AckResult { let mut buf = Vec::with_capacity(4 + 2 + 1 + 1 + 2 + 1 + pkt.data.len()); buf.write_u32::(PROTO_ID)?; buf.write_u16::(*self.remote_id.read().await)?; @@ -27,7 +27,7 @@ impl RudpShare { } buf.write_u8(tp as u8)?; - buf.write_all(pkt.data)?; + buf.write_all(pkt.data.as_ref())?; self.send_raw(&buf).await?; -- cgit v1.2.3