@@ -12,7 +12,7 @@ use crate::cmp;
12
12
use crate :: io:: { self , BorrowedBuf , Read } ;
13
13
use crate :: mem:: MaybeUninit ;
14
14
15
- pub struct Buffer {
15
+ pub ( crate ) struct Buffer {
16
16
// The buffer.
17
17
buf : Box < [ MaybeUninit < u8 > ] > ,
18
18
// The current seek offset into `buf`, must always be <= `filled`.
@@ -30,54 +30,54 @@ pub struct Buffer {
30
30
31
31
impl Buffer {
32
32
#[ inline]
33
- pub fn with_capacity ( capacity : usize ) -> Self {
33
+ pub ( crate ) fn with_capacity ( capacity : usize ) -> Self {
34
34
let buf = Box :: new_uninit_slice ( capacity) ;
35
35
Self { buf, pos : 0 , filled : 0 , initialized : 0 }
36
36
}
37
37
38
38
#[ inline]
39
- pub fn buffer ( & self ) -> & [ u8 ] {
39
+ pub ( crate ) fn buffer ( & self ) -> & [ u8 ] {
40
40
// SAFETY: self.pos and self.cap are valid, and self.cap => self.pos, and
41
41
// that region is initialized because those are all invariants of this type.
42
42
unsafe { MaybeUninit :: slice_assume_init_ref ( self . buf . get_unchecked ( self . pos ..self . filled ) ) }
43
43
}
44
44
45
45
#[ inline]
46
- pub fn capacity ( & self ) -> usize {
46
+ pub ( crate ) fn capacity ( & self ) -> usize {
47
47
self . buf . len ( )
48
48
}
49
49
50
50
#[ inline]
51
- pub fn filled ( & self ) -> usize {
51
+ pub ( crate ) fn filled ( & self ) -> usize {
52
52
self . filled
53
53
}
54
54
55
55
#[ inline]
56
- pub fn pos ( & self ) -> usize {
56
+ pub ( crate ) fn pos ( & self ) -> usize {
57
57
self . pos
58
58
}
59
59
60
60
// This is only used by a test which asserts that the initialization-tracking is correct.
61
61
#[ cfg( test) ]
62
- pub fn initialized ( & self ) -> usize {
62
+ pub ( crate ) fn initialized ( & self ) -> usize {
63
63
self . initialized
64
64
}
65
65
66
66
#[ inline]
67
- pub fn discard_buffer ( & mut self ) {
67
+ pub ( crate ) fn discard_buffer ( & mut self ) {
68
68
self . pos = 0 ;
69
69
self . filled = 0 ;
70
70
}
71
71
72
72
#[ inline]
73
- pub fn consume ( & mut self , amt : usize ) {
73
+ pub ( crate ) fn consume ( & mut self , amt : usize ) {
74
74
self . pos = cmp:: min ( self . pos + amt, self . filled ) ;
75
75
}
76
76
77
77
/// If there are `amt` bytes available in the buffer, pass a slice containing those bytes to
78
78
/// `visitor` and return true. If there are not enough bytes available, return false.
79
79
#[ 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
81
81
where
82
82
V : FnMut ( & [ u8 ] ) ,
83
83
{
@@ -92,12 +92,12 @@ impl Buffer {
92
92
}
93
93
94
94
#[ inline]
95
- pub fn unconsume ( & mut self , amt : usize ) {
95
+ pub ( crate ) fn unconsume ( & mut self , amt : usize ) {
96
96
self . pos = self . pos . saturating_sub ( amt) ;
97
97
}
98
98
99
99
#[ 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 ] > {
101
101
// If we've reached the end of our internal buffer then we need to fetch
102
102
// some more data from the reader.
103
103
// Branch using `>=` instead of the more correct `==`
0 commit comments