21
21
22
22
#[ cfg( feature = "std" ) ]
23
23
mod if_std {
24
- use futures_core:: task:: { Context , Poll } ;
25
24
use std:: cmp;
26
- use std:: io as StdIo ;
25
+ use std:: io;
27
26
use std:: ops:: DerefMut ;
28
27
use std:: pin:: Pin ;
29
28
use std:: ptr;
29
+ use std:: task:: { Context , Poll } ;
30
30
31
31
// Re-export some types from `std::io` so that users don't have to deal
32
32
// with conflicts when `use`ing `futures::io` and `std::io`.
33
33
#[ allow( unreachable_pub) ] // https://github.com/rust-lang/rust/issues/57411
34
- pub use self :: StdIo :: {
34
+ pub use io :: {
35
35
Error as Error ,
36
36
ErrorKind as ErrorKind ,
37
37
Result as Result ,
@@ -147,8 +147,8 @@ mod if_std {
147
147
fn poll_read_vectored ( self : Pin < & mut Self > , cx : & mut Context < ' _ > , bufs : & mut [ IoSliceMut < ' _ > ] )
148
148
-> Poll < Result < usize > >
149
149
{
150
- if let Some ( ref mut first_iovec) = bufs. get_mut ( 0 ) {
151
- self . poll_read ( cx, first_iovec)
150
+ if let Some ( first_iovec) = bufs. get_mut ( 0 ) {
151
+ self . poll_read ( cx, & mut * * first_iovec)
152
152
} else {
153
153
// `bufs` is empty.
154
154
Poll :: Ready ( Ok ( 0 ) )
@@ -208,8 +208,8 @@ mod if_std {
208
208
fn poll_write_vectored ( self : Pin < & mut Self > , cx : & mut Context < ' _ > , bufs : & [ IoSlice < ' _ > ] )
209
209
-> Poll < Result < usize > >
210
210
{
211
- if let Some ( ref first_iovec) = bufs. get ( 0 ) {
212
- self . poll_write ( cx, & * first_iovec)
211
+ if let Some ( first_iovec) = bufs. get ( 0 ) {
212
+ self . poll_write ( cx, & * * first_iovec)
213
213
} else {
214
214
// `bufs` is empty.
215
215
Poll :: Ready ( Ok ( 0 ) )
@@ -390,7 +390,7 @@ mod if_std {
390
390
}
391
391
}
392
392
393
- /// `unsafe` because the `StdIo ::Read` type must not access the buffer
393
+ /// `unsafe` because the `io ::Read` type must not access the buffer
394
394
/// before reading data into it.
395
395
macro_rules! unsafe_delegate_async_read_to_stdio {
396
396
( ) => {
@@ -401,13 +401,13 @@ mod if_std {
401
401
fn poll_read( mut self : Pin <& mut Self >, _: & mut Context <' _>, buf: & mut [ u8 ] )
402
402
-> Poll <Result <usize >>
403
403
{
404
- Poll :: Ready ( StdIo :: Read :: read( & mut * self , buf) )
404
+ Poll :: Ready ( io :: Read :: read( & mut * self , buf) )
405
405
}
406
406
407
407
fn poll_read_vectored( mut self : Pin <& mut Self >, _: & mut Context <' _>, bufs: & mut [ IoSliceMut <' _>] )
408
408
-> Poll <Result <usize >>
409
409
{
410
- Poll :: Ready ( StdIo :: Read :: read_vectored( & mut * self , bufs) )
410
+ Poll :: Ready ( io :: Read :: read_vectored( & mut * self , bufs) )
411
411
}
412
412
}
413
413
}
@@ -416,15 +416,15 @@ mod if_std {
416
416
unsafe_delegate_async_read_to_stdio ! ( ) ;
417
417
}
418
418
419
- impl AsyncRead for StdIo :: Repeat {
419
+ impl AsyncRead for io :: Repeat {
420
420
unsafe_delegate_async_read_to_stdio ! ( ) ;
421
421
}
422
422
423
- impl AsyncRead for StdIo :: Empty {
423
+ impl AsyncRead for io :: Empty {
424
424
unsafe_delegate_async_read_to_stdio ! ( ) ;
425
425
}
426
426
427
- impl < T : AsRef < [ u8 ] > + Unpin > AsyncRead for StdIo :: Cursor < T > {
427
+ impl < T : AsRef < [ u8 ] > + Unpin > AsyncRead for io :: Cursor < T > {
428
428
unsafe_delegate_async_read_to_stdio ! ( ) ;
429
429
}
430
430
@@ -491,17 +491,17 @@ mod if_std {
491
491
fn poll_write( mut self : Pin <& mut Self >, _: & mut Context <' _>, buf: & [ u8 ] )
492
492
-> Poll <Result <usize >>
493
493
{
494
- Poll :: Ready ( StdIo :: Write :: write( & mut * self , buf) )
494
+ Poll :: Ready ( io :: Write :: write( & mut * self , buf) )
495
495
}
496
496
497
497
fn poll_write_vectored( mut self : Pin <& mut Self >, _: & mut Context <' _>, bufs: & [ IoSlice <' _>] )
498
498
-> Poll <Result <usize >>
499
499
{
500
- Poll :: Ready ( StdIo :: Write :: write_vectored( & mut * self , bufs) )
500
+ Poll :: Ready ( io :: Write :: write_vectored( & mut * self , bufs) )
501
501
}
502
502
503
503
fn poll_flush( mut self : Pin <& mut Self >, _: & mut Context <' _>) -> Poll <Result <( ) >> {
504
- Poll :: Ready ( StdIo :: Write :: flush( & mut * self ) )
504
+ Poll :: Ready ( io :: Write :: flush( & mut * self ) )
505
505
}
506
506
507
507
fn poll_close( self : Pin <& mut Self >, cx: & mut Context <' _>) -> Poll <Result <( ) >> {
@@ -510,7 +510,7 @@ mod if_std {
510
510
}
511
511
}
512
512
513
- impl < T : AsMut < [ u8 ] > + Unpin > AsyncWrite for StdIo :: Cursor < T > {
513
+ impl < T : AsMut < [ u8 ] > + Unpin > AsyncWrite for io :: Cursor < T > {
514
514
fn poll_write (
515
515
mut self : Pin < & mut Self > ,
516
516
_: & mut Context < ' _ > ,
@@ -520,7 +520,7 @@ mod if_std {
520
520
let result = {
521
521
let out = ( & mut * self ) . get_mut ( ) . as_mut ( ) ;
522
522
let pos = cmp:: min ( out. len ( ) as u64 , position) as usize ;
523
- StdIo :: Write :: write ( & mut & mut out[ pos..] , buf)
523
+ io :: Write :: write ( & mut & mut out[ pos..] , buf)
524
524
} ;
525
525
if let Ok ( offset) = result {
526
526
self . get_mut ( ) . set_position ( position + offset as u64 ) ;
@@ -531,11 +531,11 @@ mod if_std {
531
531
fn poll_write_vectored ( self : Pin < & mut Self > , _: & mut Context < ' _ > , bufs : & [ IoSlice < ' _ > ] )
532
532
-> Poll < Result < usize > >
533
533
{
534
- Poll :: Ready ( StdIo :: Write :: write_vectored ( & mut self . get_mut ( ) . get_mut ( ) . as_mut ( ) , bufs) )
534
+ Poll :: Ready ( io :: Write :: write_vectored ( & mut self . get_mut ( ) . get_mut ( ) . as_mut ( ) , bufs) )
535
535
}
536
536
537
537
fn poll_flush ( self : Pin < & mut Self > , _: & mut Context < ' _ > ) -> Poll < Result < ( ) > > {
538
- Poll :: Ready ( StdIo :: Write :: flush ( & mut self . get_mut ( ) . get_mut ( ) . as_mut ( ) ) )
538
+ Poll :: Ready ( io :: Write :: flush ( & mut self . get_mut ( ) . get_mut ( ) . as_mut ( ) ) )
539
539
}
540
540
541
541
fn poll_close ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Result < ( ) > > {
@@ -547,7 +547,7 @@ mod if_std {
547
547
delegate_async_write_to_stdio ! ( ) ;
548
548
}
549
549
550
- impl AsyncWrite for StdIo :: Sink {
550
+ impl AsyncWrite for io :: Sink {
551
551
delegate_async_write_to_stdio ! ( ) ;
552
552
}
553
553
@@ -569,7 +569,6 @@ mod if_std {
569
569
deref_async_seek ! ( ) ;
570
570
}
571
571
572
-
573
572
impl < P > AsyncSeek for Pin < P >
574
573
where
575
574
P : DerefMut + Unpin ,
@@ -587,12 +586,12 @@ mod if_std {
587
586
fn poll_seek( mut self : Pin <& mut Self >, _: & mut Context <' _>, pos: SeekFrom )
588
587
-> Poll <Result <u64 >>
589
588
{
590
- Poll :: Ready ( StdIo :: Seek :: seek( & mut * self , pos) )
589
+ Poll :: Ready ( io :: Seek :: seek( & mut * self , pos) )
591
590
}
592
591
}
593
592
}
594
593
595
- impl < T : AsRef < [ u8 ] > + Unpin > AsyncSeek for StdIo :: Cursor < T > {
594
+ impl < T : AsRef < [ u8 ] > + Unpin > AsyncSeek for io :: Cursor < T > {
596
595
delegate_async_seek_to_stdio ! ( ) ;
597
596
}
598
597
@@ -604,8 +603,8 @@ mod if_std {
604
603
Pin :: new( & mut * * self . get_mut( ) ) . poll_fill_buf( cx)
605
604
}
606
605
607
- fn consume( self : Pin <& mut Self >, amt: usize ) {
608
- Pin :: new( & mut * * self . get_mut ( ) ) . consume( amt)
606
+ fn consume( mut self : Pin <& mut Self >, amt: usize ) {
607
+ Pin :: new( & mut * * self ) . consume( amt)
609
608
}
610
609
}
611
610
}
@@ -639,11 +638,11 @@ mod if_std {
639
638
fn poll_fill_buf<' a>( self : Pin <& ' a mut Self >, _: & mut Context <' _>)
640
639
-> Poll <Result <& ' a [ u8 ] >>
641
640
{
642
- Poll :: Ready ( StdIo :: BufRead :: fill_buf( self . get_mut( ) ) )
641
+ Poll :: Ready ( io :: BufRead :: fill_buf( self . get_mut( ) ) )
643
642
}
644
643
645
644
fn consume( self : Pin <& mut Self >, amt: usize ) {
646
- StdIo :: BufRead :: consume( self . get_mut( ) , amt)
645
+ io :: BufRead :: consume( self . get_mut( ) , amt)
647
646
}
648
647
}
649
648
}
@@ -652,11 +651,11 @@ mod if_std {
652
651
delegate_async_buf_read_to_stdio ! ( ) ;
653
652
}
654
653
655
- impl AsyncBufRead for StdIo :: Empty {
654
+ impl AsyncBufRead for io :: Empty {
656
655
delegate_async_buf_read_to_stdio ! ( ) ;
657
656
}
658
657
659
- impl < T : AsRef < [ u8 ] > + Unpin > AsyncBufRead for StdIo :: Cursor < T > {
658
+ impl < T : AsRef < [ u8 ] > + Unpin > AsyncBufRead for io :: Cursor < T > {
660
659
delegate_async_buf_read_to_stdio ! ( ) ;
661
660
}
662
661
}
0 commit comments