use std::{ io::Result as IoResult, pin::Pin, task::{Context, Poll}, }; use futures_io::{AsyncRead, AsyncWrite}; use super::Compat; use crate::io::AsyncSocket; impl AsyncSocket for Compat where S: AsyncRead + AsyncWrite + Unpin { fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8]) -> Poll> { AsyncRead::poll_read(Pin::new(&mut self.0), cx, buf) } fn poll_write(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll> { AsyncWrite::poll_write(Pin::new(&mut self.0), cx, buf) } } impl AsyncRead for Compat where S: AsyncRead + Unpin { fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8]) -> Poll> { AsyncRead::poll_read(Pin::new(&mut self.0), cx, buf) } } impl AsyncWrite for Compat where S: AsyncWrite + Unpin { fn poll_write(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll> { AsyncWrite::poll_write(Pin::new(&mut self.0), cx, buf) } fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { AsyncWrite::poll_flush(Pin::new(&mut self.0), cx) } fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { AsyncWrite::poll_close(Pin::new(&mut self.0), cx) } }