@@ -12,7 +12,7 @@ use std::io;
1212use std:: marker:: Unpin ;
1313
1414use bytes:: { Buf , Bytes } ;
15- use tokio:: io:: { AsyncRead , AsyncWrite } ;
15+ use tokio:: io:: { AsyncRead , AsyncWrite , ReadBuf } ;
1616use tokio:: sync:: oneshot;
1717
1818use crate :: common:: io:: Rewind ;
@@ -105,15 +105,11 @@ impl Upgraded {
105105}
106106
107107impl AsyncRead for Upgraded {
108- unsafe fn prepare_uninitialized_buffer ( & self , buf : & mut [ std:: mem:: MaybeUninit < u8 > ] ) -> bool {
109- self . io . prepare_uninitialized_buffer ( buf)
110- }
111-
112108 fn poll_read (
113- mut self : Pin < & mut Self > ,
109+ self : Pin < & mut Self > ,
114110 cx : & mut task:: Context < ' _ > ,
115- buf : & mut [ u8 ] ,
116- ) -> Poll < io:: Result < usize > > {
111+ buf : & mut ReadBuf < ' _ > ,
112+ ) -> Poll < io:: Result < ( ) > > {
117113 Pin :: new ( & mut self . io ) . poll_read ( cx, buf)
118114 }
119115}
@@ -127,14 +123,6 @@ impl AsyncWrite for Upgraded {
127123 Pin :: new ( & mut self . io ) . poll_write ( cx, buf)
128124 }
129125
130- fn poll_write_buf < B : Buf > (
131- mut self : Pin < & mut Self > ,
132- cx : & mut task:: Context < ' _ > ,
133- buf : & mut B ,
134- ) -> Poll < io:: Result < usize > > {
135- Pin :: new ( self . io . get_mut ( ) ) . poll_write_dyn_buf ( cx, buf)
136- }
137-
138126 fn poll_flush ( mut self : Pin < & mut Self > , cx : & mut task:: Context < ' _ > ) -> Poll < io:: Result < ( ) > > {
139127 Pin :: new ( & mut self . io ) . poll_flush ( cx)
140128 }
@@ -247,15 +235,11 @@ impl dyn Io + Send {
247235}
248236
249237impl < T : AsyncRead + Unpin > AsyncRead for ForwardsWriteBuf < T > {
250- unsafe fn prepare_uninitialized_buffer ( & self , buf : & mut [ std:: mem:: MaybeUninit < u8 > ] ) -> bool {
251- self . 0 . prepare_uninitialized_buffer ( buf)
252- }
253-
254238 fn poll_read (
255- mut self : Pin < & mut Self > ,
239+ self : Pin < & mut Self > ,
256240 cx : & mut task:: Context < ' _ > ,
257- buf : & mut [ u8 ] ,
258- ) -> Poll < io:: Result < usize > > {
241+ buf : & mut ReadBuf < ' _ > ,
242+ ) -> Poll < io:: Result < ( ) > > {
259243 Pin :: new ( & mut self . 0 ) . poll_read ( cx, buf)
260244 }
261245}
@@ -269,14 +253,6 @@ impl<T: AsyncWrite + Unpin> AsyncWrite for ForwardsWriteBuf<T> {
269253 Pin :: new ( & mut self . 0 ) . poll_write ( cx, buf)
270254 }
271255
272- fn poll_write_buf < B : Buf > (
273- mut self : Pin < & mut Self > ,
274- cx : & mut task:: Context < ' _ > ,
275- buf : & mut B ,
276- ) -> Poll < io:: Result < usize > > {
277- Pin :: new ( & mut self . 0 ) . poll_write_buf ( cx, buf)
278- }
279-
280256 fn poll_flush ( mut self : Pin < & mut Self > , cx : & mut task:: Context < ' _ > ) -> Poll < io:: Result < ( ) > > {
281257 Pin :: new ( & mut self . 0 ) . poll_flush ( cx)
282258 }
@@ -292,7 +268,7 @@ impl<T: AsyncRead + AsyncWrite + Unpin + 'static> Io for ForwardsWriteBuf<T> {
292268 cx : & mut task:: Context < ' _ > ,
293269 mut buf : & mut dyn Buf ,
294270 ) -> Poll < io:: Result < usize > > {
295- Pin :: new ( & mut self . 0 ) . poll_write_buf ( cx, & mut buf)
271+ Pin :: new ( & mut self . 0 ) . poll_write ( cx, buf. bytes ( ) )
296272 }
297273}
298274
0 commit comments