1
- use crate :: io:: Write ;
2
1
use crate :: task:: { Context , Poll } ;
3
- use futures:: { ready, AsyncWrite , Future , Stream } ;
2
+ use futures:: { ready, AsyncWrite } ;
4
3
use std:: fmt;
5
- use std:: io:: { self , IntoInnerError } ;
4
+ use std:: io;
6
5
use std:: pin:: Pin ;
7
6
8
7
const DEFAULT_CAPACITY : usize = 8 * 1024 ;
@@ -74,10 +73,10 @@ const DEFAULT_CAPACITY: usize = 8 * 1024;
74
73
/// together by the buffer, and will all be written out in one system call when
75
74
/// the `stream` is dropped.
76
75
///
77
- /// [`Write`]: ../../std/io/ trait.Write.html
78
- /// [`TcpStream::write`]: ../../std/ net/struct.TcpStream.html#method.write
79
- /// [`TcpStream`]: ../../std/ net/struct.TcpStream.html
80
- /// [`flush`]: #method .flush
76
+ /// [`Write`]: trait.Write.html
77
+ /// [`TcpStream::write`]: ../net/struct.TcpStream.html#method.write
78
+ /// [`TcpStream`]: ../net/struct.TcpStream.html
79
+ /// [`flush`]: trait.Write.html#tymethod .flush
81
80
pub struct BufWriter < W > {
82
81
inner : W ,
83
82
buf : Vec < u8 > ,
@@ -218,6 +217,7 @@ impl<W: AsyncWrite + Unpin> BufWriter<W> {
218
217
& self . buf
219
218
}
220
219
220
+
221
221
pub fn poll_flush_buf ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < io:: Result < ( ) > > {
222
222
let Self {
223
223
inner,
@@ -256,7 +256,7 @@ impl<W: AsyncWrite + Unpin> BufWriter<W> {
256
256
impl < W : AsyncWrite + Unpin > AsyncWrite for BufWriter < W > {
257
257
fn poll_write (
258
258
mut self : Pin < & mut Self > ,
259
- cx : & mut Context ,
259
+ cx : & mut Context < ' _ > ,
260
260
buf : & [ u8 ] ,
261
261
) -> Poll < io:: Result < usize > > {
262
262
if self . buf . len ( ) + buf. len ( ) > self . buf . capacity ( ) {
@@ -269,12 +269,12 @@ impl<W: AsyncWrite + Unpin> AsyncWrite for BufWriter<W> {
269
269
}
270
270
}
271
271
272
- fn poll_flush ( mut self : Pin < & mut Self > , cx : & mut Context ) -> Poll < io:: Result < ( ) > > {
272
+ fn poll_flush ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < io:: Result < ( ) > > {
273
273
ready ! ( self . as_mut( ) . poll_flush_buf( cx) ) ?;
274
274
self . inner ( ) . poll_flush ( cx)
275
275
}
276
276
277
- fn poll_close ( mut self : Pin < & mut Self > , cx : & mut Context ) -> Poll < io:: Result < ( ) > > {
277
+ fn poll_close ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < io:: Result < ( ) > > {
278
278
ready ! ( self . as_mut( ) . poll_flush_buf( cx) ) ?;
279
279
self . inner ( ) . poll_close ( cx)
280
280
}
@@ -356,7 +356,7 @@ impl<W: AsyncWrite + Unpin> LineWriter<W> {
356
356
impl < W : AsyncWrite + Unpin > AsyncWrite for LineWriter < W > {
357
357
fn poll_write (
358
358
mut self : Pin < & mut Self > ,
359
- cx : & mut Context ,
359
+ cx : & mut Context < ' _ > ,
360
360
buf : & [ u8 ] ,
361
361
) -> Poll < io:: Result < usize > > {
362
362
if self . need_flush {
@@ -379,13 +379,13 @@ impl<W: AsyncWrite + Unpin> AsyncWrite for LineWriter<W> {
379
379
}
380
380
}
381
381
382
- fn poll_flush ( mut self : Pin < & mut Self > , cx : & mut Context ) -> Poll < io:: Result < ( ) > > {
382
+ fn poll_flush ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < io:: Result < ( ) > > {
383
383
self . as_mut ( ) . inner ( ) . poll_flush ( cx) ?;
384
384
* self . need_flush ( ) = false ;
385
385
Poll :: Ready ( Ok ( ( ) ) )
386
386
}
387
387
388
- fn poll_close ( mut self : Pin < & mut Self > , cx : & mut Context ) -> Poll < io:: Result < ( ) > > {
388
+ fn poll_close ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < io:: Result < ( ) > > {
389
389
self . as_mut ( ) . inner ( ) . poll_flush ( cx) ?;
390
390
self . inner ( ) . poll_close ( cx)
391
391
}
@@ -407,6 +407,7 @@ where
407
407
}
408
408
409
409
mod tests {
410
+ #![ allow( unused_imports) ]
410
411
use super :: LineWriter ;
411
412
use crate :: prelude:: * ;
412
413
use crate :: task;
0 commit comments