@@ -20,14 +20,12 @@ mod if_std {
20
20
use std:: pin:: Pin ;
21
21
use std:: ptr;
22
22
23
- // Re-export IoVec for convenience
24
- pub use iovec:: IoVec ;
25
-
26
- // Re-export io::Error so that users don't have to deal
23
+ // Re-export some `std::io` items so that users don't have to deal
27
24
// with conflicts when `use`ing `futures::io` and `std::io`.
28
25
pub use self :: StdIo :: Error as Error ;
29
26
pub use self :: StdIo :: ErrorKind as ErrorKind ;
30
27
pub use self :: StdIo :: Result as Result ;
28
+ pub use self :: StdIo :: { IoVec as IoVec , IoVecMut as IoVecMut } ;
31
29
32
30
/// A type used to conditionally initialize buffers passed to `AsyncRead`
33
31
/// methods, modeled after `std`.
@@ -133,7 +131,7 @@ mod if_std {
133
131
/// `Interrupted`. Implementations must convert `WouldBlock` into
134
132
/// `Poll::Pending` and either internally retry or convert
135
133
/// `Interrupted` into another error kind.
136
- fn poll_vectored_read ( self : Pin < & mut Self > , cx : & mut Context < ' _ > , vec : & mut [ & mut IoVec ] )
134
+ fn poll_read_vectored ( self : Pin < & mut Self > , cx : & mut Context < ' _ > , vec : & mut [ IoVecMut < ' _ > ] )
137
135
-> Poll < Result < usize > >
138
136
{
139
137
if let Some ( ref mut first_iovec) = vec. get_mut ( 0 ) {
@@ -194,7 +192,7 @@ mod if_std {
194
192
/// `Interrupted`. Implementations must convert `WouldBlock` into
195
193
/// `Poll::Pending` and either internally retry or convert
196
194
/// `Interrupted` into another error kind.
197
- fn poll_vectored_write ( self : Pin < & mut Self > , cx : & mut Context < ' _ > , vec : & [ & IoVec ] )
195
+ fn poll_write_vectored ( self : Pin < & mut Self > , cx : & mut Context < ' _ > , vec : & [ IoVec < ' _ > ] )
198
196
-> Poll < Result < usize > >
199
197
{
200
198
if let Some ( ref first_iovec) = vec. get ( 0 ) {
@@ -253,10 +251,10 @@ mod if_std {
253
251
Pin :: new( & mut * * self ) . poll_read( cx, buf)
254
252
}
255
253
256
- fn poll_vectored_read ( mut self : Pin <& mut Self >, cx: & mut Context <' _>, vec: & mut [ & mut IoVec ] )
254
+ fn poll_read_vectored ( mut self : Pin <& mut Self >, cx: & mut Context <' _>, vec: & mut [ IoVecMut < ' _> ] )
257
255
-> Poll <Result <usize >>
258
256
{
259
- Pin :: new( & mut * * self ) . poll_vectored_read ( cx, vec)
257
+ Pin :: new( & mut * * self ) . poll_read_vectored ( cx, vec)
260
258
}
261
259
}
262
260
}
@@ -284,7 +282,7 @@ mod if_std {
284
282
Pin :: get_mut ( self ) . as_mut ( ) . poll_read ( cx, buf)
285
283
}
286
284
287
- fn poll_vectored_read ( self : Pin < & mut Self > , cx : & mut Context < ' _ > , vec : & mut [ & mut IoVec ] )
285
+ fn poll_vectored_read ( self : Pin < & mut Self > , cx : & mut Context < ' _ > , vec : & mut [ IoVecMut < ' _ > ] )
288
286
-> Poll < Result < usize > >
289
287
{
290
288
Pin :: get_mut ( self ) . as_mut ( ) . poll_vectored_read ( cx, vec)
@@ -304,6 +302,12 @@ mod if_std {
304
302
{
305
303
Poll :: Ready ( StdIo :: Read :: read( & mut * self , buf) )
306
304
}
305
+
306
+ fn poll_read_vectored( mut self : Pin <& mut Self >, _: & mut Context <' _>, vec: & mut [ IoVecMut <' _>] )
307
+ -> Poll <Result <usize >>
308
+ {
309
+ Poll :: Ready ( StdIo :: Read :: read_vectored( & mut * self , vec) )
310
+ }
307
311
}
308
312
}
309
313
@@ -327,10 +331,10 @@ mod if_std {
327
331
Pin :: new( & mut * * self ) . poll_write( cx, buf)
328
332
}
329
333
330
- fn poll_vectored_write ( mut self : Pin <& mut Self >, cx: & mut Context <' _>, vec: & [ & IoVec ] )
334
+ fn poll_write_vectored ( mut self : Pin <& mut Self >, cx: & mut Context <' _>, vec: & [ IoVec < ' _> ] )
331
335
-> Poll <Result <usize >>
332
336
{
333
- Pin :: new( & mut * * self ) . poll_vectored_write ( cx, vec)
337
+ Pin :: new( & mut * * self ) . poll_write_vectored ( cx, vec)
334
338
}
335
339
336
340
fn poll_flush( mut self : Pin <& mut Self >, cx: & mut Context <' _>) -> Poll <Result <( ) >> {
@@ -362,7 +366,7 @@ mod if_std {
362
366
Pin :: get_mut ( self ) . as_mut ( ) . poll_write ( cx, buf)
363
367
}
364
368
365
- fn poll_vectored_write ( self : Pin < & mut Self > , cx : & mut Context < ' _ > , vec : & [ & IoVec ] )
369
+ fn poll_vectored_write ( self : Pin < & mut Self > , cx : & mut Context < ' _ > , vec : & [ IoVec < ' _ > ] )
366
370
-> Poll < Result < usize > >
367
371
{
368
372
Pin :: get_mut ( self ) . as_mut ( ) . poll_vectored_write ( cx, vec)
@@ -385,6 +389,12 @@ mod if_std {
385
389
Poll :: Ready ( StdIo :: Write :: write( & mut * self , buf) )
386
390
}
387
391
392
+ fn poll_write_vectored( mut self : Pin <& mut Self >, _: & mut Context <' _>, vec: & [ IoVec <' _>] )
393
+ -> Poll <Result <usize >>
394
+ {
395
+ Poll :: Ready ( StdIo :: Write :: write_vectored( & mut * self , vec) )
396
+ }
397
+
388
398
fn poll_flush( mut self : Pin <& mut Self >, _: & mut Context <' _>) -> Poll <Result <( ) >> {
389
399
Poll :: Ready ( StdIo :: Write :: flush( & mut * self ) )
390
400
}
@@ -413,6 +423,12 @@ mod if_std {
413
423
Poll :: Ready ( result)
414
424
}
415
425
426
+ fn poll_write_vectored ( self : Pin < & mut Self > , _: & mut Context < ' _ > , vec : & [ IoVec < ' _ > ] )
427
+ -> Poll < Result < usize > >
428
+ {
429
+ Poll :: Ready ( StdIo :: Write :: write_vectored ( & mut self . get_mut ( ) . get_mut ( ) . as_mut ( ) , vec) )
430
+ }
431
+
416
432
fn poll_flush ( self : Pin < & mut Self > , _: & mut Context < ' _ > ) -> Poll < Result < ( ) > > {
417
433
Poll :: Ready ( StdIo :: Write :: flush ( & mut self . get_mut ( ) . get_mut ( ) . as_mut ( ) ) )
418
434
}
0 commit comments