Loosen requiremenst on IoImpl

This commit is contained in:
soup 2024-10-22 23:58:18 -04:00
parent 2f493c724f
commit 520f3fd949
No known key found for this signature in database
2 changed files with 10 additions and 7 deletions

View file

@ -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<Output = IoResult<Self::Incoming>>;
type TcpStream: AsyncReadLoan + AsyncWriteLoan;
type TcpStream;
fn tcp_connect(
&self,
socket: SocketAddr,

View file

@ -18,13 +18,19 @@ impl<I: IoImpl> TcpStream<I> {
}
}
impl<I: IoImpl> AsyncReadLoan for TcpStream<I> {
impl<I: IoImpl> AsyncReadLoan for TcpStream<I>
where
I::TcpStream: AsyncReadLoan,
{
async fn read<B: BufferMut>(&mut self, buf: B) -> (B, IoResult<usize>) {
self.0.read(buf).await
}
}
impl<I: IoImpl> AsyncWriteLoan for TcpStream<I> {
impl<I: IoImpl> AsyncWriteLoan for TcpStream<I>
where
I::TcpStream: AsyncWriteLoan,
{
async fn write<B: Buffer>(&mut self, buf: B) -> (B, IoResult<usize>) {
self.0.write(buf).await
}