@@ -20,14 +20,13 @@ 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
23
// Re-export some types from `std::io` 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 :: IoSlice as IoSlice ;
29
+ pub use self :: StdIo :: IoSliceMut as IoSliceMut ;
31
30
pub use self :: StdIo :: SeekFrom as SeekFrom ;
32
31
33
32
/// A type used to conditionally initialize buffers passed to `AsyncRead`
@@ -134,7 +133,7 @@ mod if_std {
134
133
/// `Interrupted`. Implementations must convert `WouldBlock` into
135
134
/// `Poll::Pending` and either internally retry or convert
136
135
/// `Interrupted` into another error kind.
137
- fn poll_vectored_read ( self : Pin < & mut Self > , cx : & mut Context < ' _ > , vec : & mut [ & mut IoVec ] )
136
+ fn poll_read_vectored ( self : Pin < & mut Self > , cx : & mut Context < ' _ > , vec : & mut [ IoSliceMut < ' _ > ] )
138
137
-> Poll < Result < usize > >
139
138
{
140
139
if let Some ( ref mut first_iovec) = vec. get_mut ( 0 ) {
@@ -195,13 +194,13 @@ mod if_std {
195
194
/// `Interrupted`. Implementations must convert `WouldBlock` into
196
195
/// `Poll::Pending` and either internally retry or convert
197
196
/// `Interrupted` into another error kind.
198
- fn poll_vectored_write ( self : Pin < & mut Self > , cx : & mut Context < ' _ > , vec : & [ & IoVec ] )
197
+ fn poll_write_vectored ( self : Pin < & mut Self > , cx : & mut Context < ' _ > , bufs : & [ IoSlice < ' _ > ] )
199
198
-> Poll < Result < usize > >
200
199
{
201
- if let Some ( ref first_iovec) = vec . get ( 0 ) {
200
+ if let Some ( ref first_iovec) = bufs . get ( 0 ) {
202
201
self . poll_write ( cx, & * first_iovec)
203
202
} else {
204
- // `vec ` is empty.
203
+ // `bufs ` is empty.
205
204
Poll :: Ready ( Ok ( 0 ) )
206
205
}
207
206
}
@@ -335,10 +334,10 @@ mod if_std {
335
334
Pin :: new( & mut * * self ) . poll_read( cx, buf)
336
335
}
337
336
338
- fn poll_vectored_read ( mut self : Pin <& mut Self >, cx: & mut Context <' _>, vec: & mut [ & mut IoVec ] )
337
+ fn poll_read_vectored ( mut self : Pin <& mut Self >, cx: & mut Context <' _>, vec: & mut [ IoSliceMut < ' _> ] )
339
338
-> Poll <Result <usize >>
340
339
{
341
- Pin :: new( & mut * * self ) . poll_vectored_read ( cx, vec)
340
+ Pin :: new( & mut * * self ) . poll_read_vectored ( cx, vec)
342
341
}
343
342
}
344
343
}
@@ -366,10 +365,10 @@ mod if_std {
366
365
Pin :: get_mut ( self ) . as_mut ( ) . poll_read ( cx, buf)
367
366
}
368
367
369
- fn poll_vectored_read ( self : Pin < & mut Self > , cx : & mut Context < ' _ > , vec : & mut [ & mut IoVec ] )
368
+ fn poll_read_vectored ( self : Pin < & mut Self > , cx : & mut Context < ' _ > , vec : & mut [ IoSliceMut < ' _ > ] )
370
369
-> Poll < Result < usize > >
371
370
{
372
- Pin :: get_mut ( self ) . as_mut ( ) . poll_vectored_read ( cx, vec)
371
+ Pin :: get_mut ( self ) . as_mut ( ) . poll_read_vectored ( cx, vec)
373
372
}
374
373
}
375
374
@@ -386,6 +385,12 @@ mod if_std {
386
385
{
387
386
Poll :: Ready ( StdIo :: Read :: read( & mut * self , buf) )
388
387
}
388
+
389
+ fn poll_read_vectored( mut self : Pin <& mut Self >, _: & mut Context <' _>, vec: & mut [ IoSliceMut <' _>] )
390
+ -> Poll <Result <usize >>
391
+ {
392
+ Poll :: Ready ( StdIo :: Read :: read_vectored( & mut * self , vec) )
393
+ }
389
394
}
390
395
}
391
396
@@ -413,10 +418,10 @@ mod if_std {
413
418
Pin :: new( & mut * * self ) . poll_write( cx, buf)
414
419
}
415
420
416
- fn poll_vectored_write ( mut self : Pin <& mut Self >, cx: & mut Context <' _>, vec : & [ & IoVec ] )
421
+ fn poll_write_vectored ( mut self : Pin <& mut Self >, cx: & mut Context <' _>, bufs : & [ IoSlice < ' _> ] )
417
422
-> Poll <Result <usize >>
418
423
{
419
- Pin :: new( & mut * * self ) . poll_vectored_write ( cx, vec )
424
+ Pin :: new( & mut * * self ) . poll_write_vectored ( cx, bufs )
420
425
}
421
426
422
427
fn poll_flush( mut self : Pin <& mut Self >, cx: & mut Context <' _>) -> Poll <Result <( ) >> {
@@ -448,10 +453,10 @@ mod if_std {
448
453
Pin :: get_mut ( self ) . as_mut ( ) . poll_write ( cx, buf)
449
454
}
450
455
451
- fn poll_vectored_write ( self : Pin < & mut Self > , cx : & mut Context < ' _ > , vec : & [ & IoVec ] )
456
+ fn poll_write_vectored ( self : Pin < & mut Self > , cx : & mut Context < ' _ > , bufs : & [ IoSlice < ' _ > ] )
452
457
-> Poll < Result < usize > >
453
458
{
454
- Pin :: get_mut ( self ) . as_mut ( ) . poll_vectored_write ( cx, vec )
459
+ Pin :: get_mut ( self ) . as_mut ( ) . poll_write_vectored ( cx, bufs )
455
460
}
456
461
457
462
fn poll_flush ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Result < ( ) > > {
@@ -471,6 +476,12 @@ mod if_std {
471
476
Poll :: Ready ( StdIo :: Write :: write( & mut * self , buf) )
472
477
}
473
478
479
+ fn poll_write_vectored( mut self : Pin <& mut Self >, _: & mut Context <' _>, bufs: & [ IoSlice <' _>] )
480
+ -> Poll <Result <usize >>
481
+ {
482
+ Poll :: Ready ( StdIo :: Write :: write_vectored( & mut * self , bufs) )
483
+ }
484
+
474
485
fn poll_flush( mut self : Pin <& mut Self >, _: & mut Context <' _>) -> Poll <Result <( ) >> {
475
486
Poll :: Ready ( StdIo :: Write :: flush( & mut * self ) )
476
487
}
@@ -499,6 +510,12 @@ mod if_std {
499
510
Poll :: Ready ( result)
500
511
}
501
512
513
+ fn poll_write_vectored ( self : Pin < & mut Self > , _: & mut Context < ' _ > , bufs : & [ IoSlice < ' _ > ] )
514
+ -> Poll < Result < usize > >
515
+ {
516
+ Poll :: Ready ( StdIo :: Write :: write_vectored ( & mut self . get_mut ( ) . get_mut ( ) . as_mut ( ) , bufs) )
517
+ }
518
+
502
519
fn poll_flush ( self : Pin < & mut Self > , _: & mut Context < ' _ > ) -> Poll < Result < ( ) > > {
503
520
Poll :: Ready ( StdIo :: Write :: flush ( & mut self . get_mut ( ) . get_mut ( ) . as_mut ( ) ) )
504
521
}
0 commit comments