@@ -186,7 +186,7 @@ where
186
186
self . read_buf . reserve ( next) ;
187
187
}
188
188
189
- let dst = self . read_buf . bytes_mut ( ) ;
189
+ let dst = self . read_buf . chunk_mut ( ) ;
190
190
let dst = unsafe { & mut * ( dst as * mut _ as * mut [ MaybeUninit < u8 > ] ) } ;
191
191
let mut buf = ReadBuf :: uninit ( dst) ;
192
192
match Pin :: new ( & mut self . io ) . poll_read ( cx, & mut buf) {
@@ -231,10 +231,11 @@ where
231
231
return self . poll_flush_flattened ( cx) ;
232
232
}
233
233
234
+ const MAX_WRITEV_BUFS : usize = 64 ;
234
235
loop {
235
236
let n = {
236
- let mut iovs = [ IoSlice :: new ( & [ ] ) ; crate :: common :: io :: MAX_WRITEV_BUFS ] ;
237
- let len = self . write_buf . bytes_vectored ( & mut iovs) ;
237
+ let mut iovs = [ IoSlice :: new ( & [ ] ) ; MAX_WRITEV_BUFS ] ;
238
+ let len = self . write_buf . chunks_vectored ( & mut iovs) ;
238
239
ready ! ( Pin :: new( & mut self . io) . poll_write_vectored( cx, & iovs[ ..len] ) ) ?
239
240
} ;
240
241
// TODO(eliza): we have to do this manually because
@@ -262,7 +263,7 @@ where
262
263
/// that skips some bookkeeping around using multiple buffers.
263
264
fn poll_flush_flattened ( & mut self , cx : & mut task:: Context < ' _ > ) -> Poll < io:: Result < ( ) > > {
264
265
loop {
265
- let n = ready ! ( Pin :: new( & mut self . io) . poll_write( cx, self . write_buf. headers. bytes ( ) ) ) ?;
266
+ let n = ready ! ( Pin :: new( & mut self . io) . poll_write( cx, self . write_buf. headers. chunk ( ) ) ) ?;
266
267
debug ! ( "flushed {} bytes" , n) ;
267
268
self . write_buf . headers . advance ( n) ;
268
269
if self . write_buf . headers . remaining ( ) == 0 {
@@ -433,7 +434,7 @@ impl<T: AsRef<[u8]>> Buf for Cursor<T> {
433
434
}
434
435
435
436
#[ inline]
436
- fn bytes ( & self ) -> & [ u8 ] {
437
+ fn chunk ( & self ) -> & [ u8 ] {
437
438
& self . bytes . as_ref ( ) [ self . pos ..]
438
439
}
439
440
@@ -487,7 +488,7 @@ where
487
488
//but accomplishes the same result.
488
489
loop {
489
490
let adv = {
490
- let slice = buf. bytes ( ) ;
491
+ let slice = buf. chunk ( ) ;
491
492
if slice. is_empty ( ) {
492
493
return ;
493
494
}
@@ -534,12 +535,12 @@ impl<B: Buf> Buf for WriteBuf<B> {
534
535
}
535
536
536
537
#[ inline]
537
- fn bytes ( & self ) -> & [ u8 ] {
538
- let headers = self . headers . bytes ( ) ;
538
+ fn chunk ( & self ) -> & [ u8 ] {
539
+ let headers = self . headers . chunk ( ) ;
539
540
if !headers. is_empty ( ) {
540
541
headers
541
542
} else {
542
- self . queue . bytes ( )
543
+ self . queue . chunk ( )
543
544
}
544
545
}
545
546
@@ -559,9 +560,9 @@ impl<B: Buf> Buf for WriteBuf<B> {
559
560
}
560
561
561
562
#[ inline]
562
- fn bytes_vectored < ' t > ( & ' t self , dst : & mut [ IoSlice < ' t > ] ) -> usize {
563
- let n = self . headers . bytes_vectored ( dst) ;
564
- self . queue . bytes_vectored ( & mut dst[ n..] ) + n
563
+ fn chunks_vectored < ' t > ( & ' t self , dst : & mut [ IoSlice < ' t > ] ) -> usize {
564
+ let n = self . headers . chunks_vectored ( dst) ;
565
+ self . queue . chunks_vectored ( & mut dst[ n..] ) + n
565
566
}
566
567
}
567
568
0 commit comments