From 520f3fd949b4428f15f3d27b8238d05535df6157 Mon Sep 17 00:00:00 2001 From: soup Date: Tue, 22 Oct 2024 23:58:18 -0400 Subject: [PATCH] Loosen requiremenst on IoImpl --- src/io_impl/mod.rs | 7 ++----- src/net.rs | 10 ++++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/io_impl/mod.rs b/src/io_impl/mod.rs index f5f4ff2..e64f78c 100644 --- a/src/io_impl/mod.rs +++ b/src/io_impl/mod.rs @@ -1,7 +1,4 @@ -use crate::{ - aliases::IoResult, - io::{AsyncReadLoan, AsyncWriteLoan}, -}; +use crate::aliases::IoResult; use std::{future::Future, net::SocketAddr, time::Duration}; #[cfg(feature = "io_uring")] @@ -26,7 +23,7 @@ pub trait IoImpl { listener: &mut Self::TcpListener, ) -> impl Future>; - type TcpStream: AsyncReadLoan + AsyncWriteLoan; + type TcpStream; fn tcp_connect( &self, socket: SocketAddr, diff --git a/src/net.rs b/src/net.rs index bd7abf3..11fed13 100644 --- a/src/net.rs +++ b/src/net.rs @@ -18,13 +18,19 @@ impl TcpStream { } } -impl AsyncReadLoan for TcpStream { +impl AsyncReadLoan for TcpStream +where + I::TcpStream: AsyncReadLoan, +{ async fn read(&mut self, buf: B) -> (B, IoResult) { self.0.read(buf).await } } -impl AsyncWriteLoan for TcpStream { +impl AsyncWriteLoan for TcpStream +where + I::TcpStream: AsyncWriteLoan, +{ async fn write(&mut self, buf: B) -> (B, IoResult) { self.0.write(buf).await }