@@ -8,7 +8,7 @@ use std::pin::Pin;
88use  std:: task:: { Context ,  Poll } ; 
99use  tokio:: io:: { AsyncRead ,  AsyncWrite ,  ReadBuf } ; 
1010
11- use  std:: io:: { self ,  Cursor ,   IoSlice } ; 
11+ use  std:: io:: { self ,  Cursor } ; 
1212
1313// A macro to get around a method needing to borrow &mut self 
1414macro_rules!  limited_write_buf { 
@@ -44,9 +44,6 @@ struct Encoder<B> {
4444
4545    /// Max frame size, this is specified by the peer 
4646     max_frame_size :  FrameSize , 
47- 
48-     /// Whether or not the wrapped `AsyncWrite` supports vectored IO. 
49-      is_write_vectored :  bool , 
5047} 
5148
5249#[ derive( Debug ) ]  
7673    B :  Buf , 
7774{ 
7875    pub  fn  new ( inner :  T )  -> FramedWrite < T ,  B >  { 
79-         let  is_write_vectored = inner. is_write_vectored ( ) ; 
8076        FramedWrite  { 
8177            inner, 
8278            encoder :  Encoder  { 
8581                next :  None , 
8682                last_data_frame :  None , 
8783                max_frame_size :  frame:: DEFAULT_MAX_FRAME_SIZE , 
88-                 is_write_vectored, 
8984            } , 
9085        } 
9186    } 
@@ -126,21 +121,11 @@ where
126121                    Some ( Next :: Data ( ref  mut  frame) )  => { 
127122                        tracing:: trace!( queued_data_frame = true ) ; 
128123                        let  mut  buf = ( & mut  self . encoder . buf ) . chain ( frame. payload_mut ( ) ) ; 
129-                         ready ! ( write( 
130-                             & mut  self . inner, 
131-                             self . encoder. is_write_vectored, 
132-                             & mut  buf, 
133-                             cx, 
134-                         ) ) ?
124+                         ready ! ( write( & mut  self . inner,  & mut  buf,  cx, ) ) ?
135125                    } 
136126                    _ => { 
137127                        tracing:: trace!( queued_data_frame = false ) ; 
138-                         ready ! ( write( 
139-                             & mut  self . inner, 
140-                             self . encoder. is_write_vectored, 
141-                             & mut  self . encoder. buf, 
142-                             cx, 
143-                         ) ) ?
128+                         ready ! ( write( & mut  self . inner,  & mut  self . encoder. buf,  cx, ) ) ?
144129                    } 
145130                } 
146131            } 
@@ -165,26 +150,12 @@ where
165150    } 
166151} 
167152
168- fn  write < T ,  B > ( 
169-     writer :  & mut  T , 
170-     is_write_vectored :  bool , 
171-     buf :  & mut  B , 
172-     cx :  & mut  Context < ' _ > , 
173- )  -> Poll < io:: Result < ( ) > > 
153+ fn  write < T ,  B > ( writer :  & mut  T ,  buf :  & mut  B ,  cx :  & mut  Context < ' _ > )  -> Poll < io:: Result < ( ) > > 
174154where 
175155    T :  AsyncWrite  + Unpin , 
176156    B :  Buf , 
177157{ 
178-     // TODO(eliza): when tokio-util 0.5.1 is released, this 
179-     // could just use `poll_write_buf`... 
180-     const  MAX_IOVS :  usize  = 64 ; 
181-     let  n = if  is_write_vectored { 
182-         let  mut  bufs = [ IoSlice :: new ( & [ ] ) ;  MAX_IOVS ] ; 
183-         let  cnt = buf. chunks_vectored ( & mut  bufs) ; 
184-         ready ! ( Pin :: new( writer) . poll_write_vectored( cx,  & bufs[ ..cnt] ) ) ?
185-     }  else  { 
186-         ready ! ( Pin :: new( writer) . poll_write( cx,  buf. chunk( ) ) ) ?
187-     } ; 
158+     let  n = ready ! ( tokio_util:: io:: poll_write_buf( Pin :: new( writer) ,  cx,  buf) ) ?; 
188159    buf. advance ( n) ; 
189160    Ok ( ( ) ) . into ( ) 
190161} 
0 commit comments