aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLizzy Fleckenstein <eliasfleckenstein@web.de>2023-02-15 14:27:59 +0100
committerLizzy Fleckenstein <eliasfleckenstein@web.de>2023-02-15 14:27:59 +0100
commit45d7cd0049b9349de428945c4a7c9b73cb0f461d (patch)
treefe0f58428571b01f2680c5d1eed1da7b970fed5a
parentea481ae3539e27a98ace48e746fea4a2cbf4d557 (diff)
downloadmt_rudp-45d7cd0049b9349de428945c4a7c9b73cb0f461d.tar.xz
Use delegate instead of Deref
-rw-r--r--Cargo.toml1
-rw-r--r--src/lib.rs19
2 files changed, 8 insertions, 12 deletions
diff --git a/Cargo.toml b/Cargo.toml
index a15ed83..0b5f690 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,6 +7,7 @@ edition = "2021"
async-recursion = "1.0.0"
async-trait = "0.1.60"
byteorder = "1.4.3"
+delegate = "0.9.0"
num_enum = "0.5.7"
thiserror = "1.0.38"
tokio = { version = "1.23.0", features = ["sync", "time", "net", "signal", "macros", "rt"] }
diff --git a/src/lib.rs b/src/lib.rs
index 334692a..76f0311 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -10,8 +10,9 @@ mod send;
pub use prelude::*;
use async_trait::async_trait;
+use delegate::delegate;
use num_enum::TryFromPrimitive;
-use std::{cell::OnceCell, collections::HashMap, io, ops, sync::Arc, time::Instant};
+use std::{cell::OnceCell, collections::HashMap, io, sync::Arc, time::Instant};
use tokio::{
sync::{mpsc, watch, Mutex, RwLock},
task::JoinSet,
@@ -122,17 +123,11 @@ macro_rules! impl_share {
impl_share!(RudpReceiver);
impl_share!(RudpSender);
-impl<S: UdpSender> ops::Deref for RudpReceiver<S> {
- type Target = mpsc::UnboundedReceiver<InPkt>;
-
- fn deref(&self) -> &Self::Target {
- &self.pkt_rx
- }
-}
-
-impl<S: UdpSender> ops::DerefMut for RudpReceiver<S> {
- fn deref_mut(&mut self) -> &mut Self::Target {
- &mut self.pkt_rx
+impl<S: UdpSender> RudpReceiver<S> {
+ delegate! {
+ to self.pkt_rx {
+ pub async fn recv(&mut self) -> Option<InPkt>;
+ }
}
}