@@ -12,7 +12,7 @@ use crate::cmp;
1212use  crate :: io:: { self ,  BorrowedBuf ,  Read } ; 
1313use  crate :: mem:: MaybeUninit ; 
1414
15- pub  struct  Buffer  { 
15+ pub ( crate )  struct  Buffer  { 
1616    // The buffer. 
1717    buf :  Box < [ MaybeUninit < u8 > ] > , 
1818    // The current seek offset into `buf`, must always be <= `filled`. 
@@ -30,54 +30,54 @@ pub struct Buffer {
3030
3131impl  Buffer  { 
3232    #[ inline]  
33-     pub  fn  with_capacity ( capacity :  usize )  -> Self  { 
33+     pub ( crate )  fn  with_capacity ( capacity :  usize )  -> Self  { 
3434        let  buf = Box :: new_uninit_slice ( capacity) ; 
3535        Self  {  buf,  pos :  0 ,  filled :  0 ,  initialized :  0  } 
3636    } 
3737
3838    #[ inline]  
39-     pub  fn  buffer ( & self )  -> & [ u8 ]  { 
39+     pub ( crate )  fn  buffer ( & self )  -> & [ u8 ]  { 
4040        // SAFETY: self.pos and self.cap are valid, and self.cap => self.pos, and 
4141        // that region is initialized because those are all invariants of this type. 
4242        unsafe  {  MaybeUninit :: slice_assume_init_ref ( self . buf . get_unchecked ( self . pos ..self . filled ) )  } 
4343    } 
4444
4545    #[ inline]  
46-     pub  fn  capacity ( & self )  -> usize  { 
46+     pub ( crate )  fn  capacity ( & self )  -> usize  { 
4747        self . buf . len ( ) 
4848    } 
4949
5050    #[ inline]  
51-     pub  fn  filled ( & self )  -> usize  { 
51+     pub ( crate )  fn  filled ( & self )  -> usize  { 
5252        self . filled 
5353    } 
5454
5555    #[ inline]  
56-     pub  fn  pos ( & self )  -> usize  { 
56+     pub ( crate )  fn  pos ( & self )  -> usize  { 
5757        self . pos 
5858    } 
5959
6060    // This is only used by a test which asserts that the initialization-tracking is correct. 
6161    #[ cfg( test) ]  
62-     pub  fn  initialized ( & self )  -> usize  { 
62+     pub ( crate )  fn  initialized ( & self )  -> usize  { 
6363        self . initialized 
6464    } 
6565
6666    #[ inline]  
67-     pub  fn  discard_buffer ( & mut  self )  { 
67+     pub ( crate )  fn  discard_buffer ( & mut  self )  { 
6868        self . pos  = 0 ; 
6969        self . filled  = 0 ; 
7070    } 
7171
7272    #[ inline]  
73-     pub  fn  consume ( & mut  self ,  amt :  usize )  { 
73+     pub ( crate )  fn  consume ( & mut  self ,  amt :  usize )  { 
7474        self . pos  = cmp:: min ( self . pos  + amt,  self . filled ) ; 
7575    } 
7676
7777    /// If there are `amt` bytes available in the buffer, pass a slice containing those bytes to 
7878     /// `visitor` and return true. If there are not enough bytes available, return false. 
7979     #[ inline]  
80-     pub  fn  consume_with < V > ( & mut  self ,  amt :  usize ,  mut  visitor :  V )  -> bool 
80+     pub ( crate )  fn  consume_with < V > ( & mut  self ,  amt :  usize ,  mut  visitor :  V )  -> bool 
8181    where 
8282        V :  FnMut ( & [ u8 ] ) , 
8383    { 
@@ -92,12 +92,12 @@ impl Buffer {
9292    } 
9393
9494    #[ inline]  
95-     pub  fn  unconsume ( & mut  self ,  amt :  usize )  { 
95+     pub ( crate )  fn  unconsume ( & mut  self ,  amt :  usize )  { 
9696        self . pos  = self . pos . saturating_sub ( amt) ; 
9797    } 
9898
9999    #[ inline]  
100-     pub  fn  fill_buf ( & mut  self ,  mut  reader :  impl  Read )  -> io:: Result < & [ u8 ] >  { 
100+     pub ( crate )  fn  fill_buf ( & mut  self ,  mut  reader :  impl  Read )  -> io:: Result < & [ u8 ] >  { 
101101        // If we've reached the end of our internal buffer then we need to fetch 
102102        // some more data from the reader. 
103103        // Branch using `>=` instead of the more correct `==` 
0 commit comments