@@ -281,7 +281,7 @@ pub use self::{
281
281
} ;
282
282
283
283
#[ unstable( feature = "read_buf" , issue = "78485" ) ]
284
- pub use self :: readbuf:: ReadBuf ;
284
+ pub use self :: readbuf:: { ReadBuf , ReadBufRef } ;
285
285
pub ( crate ) use error:: const_io_error;
286
286
287
287
mod buffered;
@@ -372,7 +372,7 @@ pub(crate) fn default_read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>
372
372
read_buf. assume_init ( initialized) ;
373
373
}
374
374
375
- match r. read_buf ( & mut read_buf) {
375
+ match r. read_buf ( read_buf. borrow ( ) ) {
376
376
Ok ( ( ) ) => { }
377
377
Err ( e) if e. kind ( ) == ErrorKind :: Interrupted => continue ,
378
378
Err ( e) => return Err ( e) ,
@@ -464,7 +464,7 @@ pub(crate) fn default_read_exact<R: Read + ?Sized>(this: &mut R, mut buf: &mut [
464
464
}
465
465
}
466
466
467
- pub ( crate ) fn default_read_buf < F > ( read : F , buf : & mut ReadBuf < ' _ > ) -> Result < ( ) >
467
+ pub ( crate ) fn default_read_buf < F > ( read : F , mut buf : ReadBufRef < ' _ , ' _ > ) -> Result < ( ) >
468
468
where
469
469
F : FnOnce ( & mut [ u8 ] ) -> Result < usize > ,
470
470
{
@@ -811,7 +811,7 @@ pub trait Read {
811
811
///
812
812
/// The default implementation delegates to `read`.
813
813
#[ unstable( feature = "read_buf" , issue = "78485" ) ]
814
- fn read_buf ( & mut self , buf : & mut ReadBuf < ' _ > ) -> Result < ( ) > {
814
+ fn read_buf ( & mut self , buf : ReadBufRef < ' _ , ' _ > ) -> Result < ( ) > {
815
815
default_read_buf ( |b| self . read ( b) , buf)
816
816
}
817
817
@@ -820,10 +820,10 @@ pub trait Read {
820
820
/// This is equivalent to the [`read_exact`](Read::read_exact) method, except that it is passed a [`ReadBuf`] rather than `[u8]` to
821
821
/// allow use with uninitialized buffers.
822
822
#[ unstable( feature = "read_buf" , issue = "78485" ) ]
823
- fn read_buf_exact ( & mut self , buf : & mut ReadBuf < ' _ > ) -> Result < ( ) > {
823
+ fn read_buf_exact ( & mut self , mut buf : ReadBufRef < ' _ , ' _ > ) -> Result < ( ) > {
824
824
while buf. remaining ( ) > 0 {
825
825
let prev_filled = buf. filled ( ) . len ( ) ;
826
- match self . read_buf ( buf) {
826
+ match self . read_buf ( buf. reborrow ( ) ) {
827
827
Ok ( ( ) ) => { }
828
828
Err ( e) if e. kind ( ) == ErrorKind :: Interrupted => continue ,
829
829
Err ( e) => return Err ( e) ,
@@ -2565,7 +2565,7 @@ impl<T: Read> Read for Take<T> {
2565
2565
Ok ( n)
2566
2566
}
2567
2567
2568
- fn read_buf ( & mut self , buf : & mut ReadBuf < ' _ > ) -> Result < ( ) > {
2568
+ fn read_buf ( & mut self , mut buf : ReadBufRef < ' _ , ' _ > ) -> Result < ( ) > {
2569
2569
// Don't call into inner reader at all at EOF because it may still block
2570
2570
if self . limit == 0 {
2571
2571
return Ok ( ( ) ) ;
@@ -2589,7 +2589,7 @@ impl<T: Read> Read for Take<T> {
2589
2589
sliced_buf. assume_init ( extra_init) ;
2590
2590
}
2591
2591
2592
- self . inner . read_buf ( & mut sliced_buf) ?;
2592
+ self . inner . read_buf ( sliced_buf. borrow ( ) ) ?;
2593
2593
2594
2594
let new_init = sliced_buf. initialized_len ( ) ;
2595
2595
let filled = sliced_buf. filled_len ( ) ;
@@ -2605,7 +2605,7 @@ impl<T: Read> Read for Take<T> {
2605
2605
2606
2606
self . limit -= filled as u64 ;
2607
2607
} else {
2608
- self . inner . read_buf ( buf) ?;
2608
+ self . inner . read_buf ( buf. reborrow ( ) ) ?;
2609
2609
2610
2610
//inner may unfill
2611
2611
self . limit -= buf. filled_len ( ) . saturating_sub ( prev_filled) as u64 ;
0 commit comments