1
- use std:: io:: { Error , Read } ;
2
1
use std:: mem;
3
2
4
3
use futures:: { Future , Poll } ;
@@ -16,32 +15,32 @@ enum State<R, T> {
16
15
///
17
16
/// The returned future will resolve to both the I/O stream and the buffer
18
17
/// as well as the number of bytes read once the read operation is completed.
19
- pub fn read < R , T > ( rd : R , buf : T ) -> ReadOnce < R , T >
20
- where R : Read ,
18
+ pub fn read < R , T > ( rd : R , buf : T ) -> Read < R , T >
19
+ where R : :: std :: io :: Read ,
21
20
T : AsMut < [ u8 ] >
22
21
{
23
- ReadOnce { state : State :: Pending { rd : rd, buf : buf } }
22
+ Read { state : State :: Pending { rd : rd, buf : buf } }
24
23
}
25
24
26
25
/// A future which can be used to easily read available number of bytes to fill
27
26
/// a buffer.
28
27
///
29
28
/// Created by the [`read`] function.
30
- pub struct ReadOnce < R , T > {
29
+ pub struct Read < R , T > {
31
30
state : State < R , T > ,
32
31
}
33
32
34
- impl < R , T > Future for ReadOnce < R , T >
35
- where R : Read ,
33
+ impl < R , T > Future for Read < R , T >
34
+ where R : :: std :: io :: Read ,
36
35
T : AsMut < [ u8 ] >
37
36
{
38
37
type Item = ( R , T , usize ) ;
39
- type Error = Error ;
38
+ type Error = :: std :: io :: Error ;
40
39
41
- fn poll ( & mut self ) -> Poll < ( R , T , usize ) , Error > {
40
+ fn poll ( & mut self ) -> Poll < ( R , T , usize ) , :: std :: io :: Error > {
42
41
let nread = match self . state {
43
42
State :: Pending { ref mut rd, ref mut buf } => try_nb ! ( rd. read( & mut buf. as_mut( ) [ ..] ) ) ,
44
- State :: Empty => panic ! ( "poll a ReadOnce after it's done" ) ,
43
+ State :: Empty => panic ! ( "poll a Read after it's done" ) ,
45
44
} ;
46
45
47
46
match mem:: replace ( & mut self . state , State :: Empty ) {
0 commit comments