aboutsummaryrefslogtreecommitdiff
path: root/src/send.rs
diff options
context:
space:
mode:
authorLizzy Fleckenstein <eliasfleckenstein@web.de>2023-02-15 22:04:42 +0100
committerLizzy Fleckenstein <eliasfleckenstein@web.de>2023-02-15 22:04:42 +0100
commit9498c45d1291c0b2343339bad624d0dc0ca0a934 (patch)
tree5009bdb91b2678b25905800447605b8e289c4efd /src/send.rs
parent1d4ebed25ff3e05d2fac70a040901fd3ea3029eb (diff)
downloadmt_rudp-9498c45d1291c0b2343339bad624d0dc0ca0a934.tar.xz
Use Cow for Pkt
Diffstat (limited to 'src/send.rs')
-rw-r--r--src/send.rs6
1 files changed, 3 insertions, 3 deletions
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<Option<watch::Receiver<bool>>>;
impl<S: UdpSender> RudpSender<S> {
- 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<S: UdpSender> RudpShare<S> {
- 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::<BigEndian>(PROTO_ID)?;
buf.write_u16::<BigEndian>(*self.remote_id.read().await)?;
@@ -27,7 +27,7 @@ impl<S: UdpSender> RudpShare<S> {
}
buf.write_u8(tp as u8)?;
- buf.write_all(pkt.data)?;
+ buf.write_all(pkt.data.as_ref())?;
self.send_raw(&buf).await?;