]> git.lizzy.rs Git - mt_rudp.git/blobdiff - src/common.rs
Use Cow for Pkt
[mt_rudp.git] / src / common.rs
index 797ccd1501fb205b11b1541d564aa5d943ad4da5..4e32edcce127c15236e7b8c6c63f24faa6d172c6 100644 (file)
@@ -2,7 +2,7 @@ use super::*;
 use async_trait::async_trait;
 use delegate::delegate;
 use num_enum::TryFromPrimitive;
-use std::{io, sync::Arc};
+use std::{borrow::Cow, io, sync::Arc};
 use tokio::sync::mpsc;
 
 pub const PROTO_ID: u32 = 0x4f457403;
@@ -50,13 +50,13 @@ pub enum CtlType {
 }
 
 #[derive(Debug)]
-pub struct Pkt<T> {
+pub struct Pkt<'a> {
     pub unrel: bool,
     pub chan: u8,
-    pub data: T,
+    pub data: Cow<'a, [u8]>,
 }
 
-pub type InPkt = Result<Pkt<Vec<u8>>, error::Error>;
+pub type InPkt = Result<Pkt<'static>, Error>;
 
 #[derive(Debug)]
 pub struct RudpReceiver<S: UdpSender> {