@@ -7,8 +7,9 @@ use bytes::{Buf, BufMut, BytesMut};
77use  std:: pin:: Pin ; 
88use  std:: task:: { Context ,  Poll } ; 
99use  tokio:: io:: { AsyncRead ,  AsyncWrite ,  ReadBuf } ; 
10+ use  tokio_util:: io:: poll_write_buf; 
1011
11- use  std:: io:: { self ,  Cursor ,   IoSlice } ; 
12+ use  std:: io:: { self ,  Cursor } ; 
1213
1314// A macro to get around a method needing to borrow &mut self 
1415macro_rules!  limited_write_buf { 
@@ -44,9 +45,6 @@ struct Encoder<B> {
4445
4546    /// Max frame size, this is specified by the peer 
4647     max_frame_size :  FrameSize , 
47- 
48-     /// Whether or not the wrapped `AsyncWrite` supports vectored IO. 
49-      is_write_vectored :  bool , 
5048} 
5149
5250#[ derive( Debug ) ]  
7674    B :  Buf , 
7775{ 
7876    pub  fn  new ( inner :  T )  -> FramedWrite < T ,  B >  { 
79-         let  is_write_vectored = inner. is_write_vectored ( ) ; 
8077        FramedWrite  { 
8178            inner, 
8279            encoder :  Encoder  { 
8582                next :  None , 
8683                last_data_frame :  None , 
8784                max_frame_size :  frame:: DEFAULT_MAX_FRAME_SIZE , 
88-                 is_write_vectored, 
8985            } , 
9086        } 
9187    } 
@@ -126,21 +122,15 @@ where
126122                    Some ( Next :: Data ( ref  mut  frame) )  => { 
127123                        tracing:: trace!( queued_data_frame = true ) ; 
128124                        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-                         ) ) ?
125+                         ready ! ( poll_write_buf( Pin :: new( & mut  self . inner) ,  cx,  & mut  buf) ) ?; 
135126                    } 
136127                    _ => { 
137128                        tracing:: trace!( queued_data_frame = false ) ; 
138-                         ready ! ( write( 
139-                             & mut  self . inner, 
140-                             self . encoder. is_write_vectored, 
141-                             & mut  self . encoder. buf, 
129+                         ready ! ( poll_write_buf( 
130+                             Pin :: new( & mut  self . inner) , 
142131                            cx, 
143-                         ) ) ?
132+                             & mut  self . encoder. buf
133+                         ) ) ?; 
144134                    } 
145135                } 
146136            } 
@@ -165,30 +155,6 @@ where
165155    } 
166156} 
167157
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 < ( ) > > 
174- where 
175-     T :  AsyncWrite  + Unpin , 
176-     B :  Buf , 
177- { 
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-     } ; 
188-     buf. advance ( n) ; 
189-     Ok ( ( ) ) . into ( ) 
190- } 
191- 
192158#[ must_use]  
193159enum  ControlFlow  { 
194160    Continue , 
0 commit comments