@@ -16,7 +16,7 @@ macro_rules! buf_get_impl {
16
16
// this Option<ret> trick is to avoid keeping a borrow on self
17
17
// when advance() is called (mut borrow) and to call bytes() only once
18
18
let ret = $this
19
- . bytes ( )
19
+ . chunk ( )
20
20
. get( ..SIZE )
21
21
. map( |src| unsafe { $typ:: $conv( * ( src as * const _ as * const [ _; SIZE ] ) ) } ) ;
22
22
@@ -78,7 +78,7 @@ pub trait Buf {
78
78
/// the buffer.
79
79
///
80
80
/// This value is greater than or equal to the length of the slice returned
81
- /// by `bytes `.
81
+ /// by `chunk() `.
82
82
///
83
83
/// # Examples
84
84
///
@@ -115,31 +115,31 @@ pub trait Buf {
115
115
///
116
116
/// let mut buf = &b"hello world"[..];
117
117
///
118
- /// assert_eq!(buf.bytes (), &b"hello world"[..]);
118
+ /// assert_eq!(buf.chunk (), &b"hello world"[..]);
119
119
///
120
120
/// buf.advance(6);
121
121
///
122
- /// assert_eq!(buf.bytes (), &b"world"[..]);
122
+ /// assert_eq!(buf.chunk (), &b"world"[..]);
123
123
/// ```
124
124
///
125
125
/// # Implementer notes
126
126
///
127
127
/// This function should never panic. Once the end of the buffer is reached,
128
- /// i.e., `Buf::remaining` returns 0, calls to `bytes ` should return an
128
+ /// i.e., `Buf::remaining` returns 0, calls to `chunk() ` should return an
129
129
/// empty slice.
130
- fn bytes ( & self ) -> & [ u8 ] ;
130
+ fn chunk ( & self ) -> & [ u8 ] ;
131
131
132
132
/// Fills `dst` with potentially multiple slices starting at `self`'s
133
133
/// current position.
134
134
///
135
- /// If the `Buf` is backed by disjoint slices of bytes, `bytes_vectored ` enables
135
+ /// If the `Buf` is backed by disjoint slices of bytes, `chunk_vectored ` enables
136
136
/// fetching more than one slice at once. `dst` is a slice of `IoSlice`
137
137
/// references, enabling the slice to be directly used with [`writev`]
138
138
/// without any further conversion. The sum of the lengths of all the
139
139
/// buffers in `dst` will be less than or equal to `Buf::remaining()`.
140
140
///
141
141
/// The entries in `dst` will be overwritten, but the data **contained** by
142
- /// the slices **will not** be modified. If `bytes_vectored ` does not fill every
142
+ /// the slices **will not** be modified. If `chunk_vectored ` does not fill every
143
143
/// entry in `dst`, then `dst` is guaranteed to contain all remaining slices
144
144
/// in `self.
145
145
///
@@ -149,21 +149,21 @@ pub trait Buf {
149
149
/// # Implementer notes
150
150
///
151
151
/// This function should never panic. Once the end of the buffer is reached,
152
- /// i.e., `Buf::remaining` returns 0, calls to `bytes_vectored ` must return 0
152
+ /// i.e., `Buf::remaining` returns 0, calls to `chunk_vectored ` must return 0
153
153
/// without mutating `dst`.
154
154
///
155
155
/// Implementations should also take care to properly handle being called
156
156
/// with `dst` being a zero length slice.
157
157
///
158
158
/// [`writev`]: http://man7.org/linux/man-pages/man2/readv.2.html
159
159
#[ cfg( feature = "std" ) ]
160
- fn bytes_vectored < ' a > ( & ' a self , dst : & mut [ IoSlice < ' a > ] ) -> usize {
160
+ fn chunks_vectored < ' a > ( & ' a self , dst : & mut [ IoSlice < ' a > ] ) -> usize {
161
161
if dst. is_empty ( ) {
162
162
return 0 ;
163
163
}
164
164
165
165
if self . has_remaining ( ) {
166
- dst[ 0 ] = IoSlice :: new ( self . bytes ( ) ) ;
166
+ dst[ 0 ] = IoSlice :: new ( self . chunk ( ) ) ;
167
167
1
168
168
} else {
169
169
0
@@ -172,7 +172,7 @@ pub trait Buf {
172
172
173
173
/// Advance the internal cursor of the Buf
174
174
///
175
- /// The next call to `bytes ` will return a slice starting `cnt` bytes
175
+ /// The next call to `chunk() ` will return a slice starting `cnt` bytes
176
176
/// further into the underlying buffer.
177
177
///
178
178
/// # Examples
@@ -182,11 +182,11 @@ pub trait Buf {
182
182
///
183
183
/// let mut buf = &b"hello world"[..];
184
184
///
185
- /// assert_eq!(buf.bytes (), &b"hello world"[..]);
185
+ /// assert_eq!(buf.chunk (), &b"hello world"[..]);
186
186
///
187
187
/// buf.advance(6);
188
188
///
189
- /// assert_eq!(buf.bytes (), &b"world"[..]);
189
+ /// assert_eq!(buf.chunk (), &b"world"[..]);
190
190
/// ```
191
191
///
192
192
/// # Panics
@@ -253,7 +253,7 @@ pub trait Buf {
253
253
let cnt;
254
254
255
255
unsafe {
256
- let src = self . bytes ( ) ;
256
+ let src = self . chunk ( ) ;
257
257
cnt = cmp:: min ( src. len ( ) , dst. len ( ) - off) ;
258
258
259
259
ptr:: copy_nonoverlapping ( src. as_ptr ( ) , dst[ off..] . as_mut_ptr ( ) , cnt) ;
@@ -283,7 +283,7 @@ pub trait Buf {
283
283
/// This function panics if there is no more remaining data in `self`.
284
284
fn get_u8 ( & mut self ) -> u8 {
285
285
assert ! ( self . remaining( ) >= 1 ) ;
286
- let ret = self . bytes ( ) [ 0 ] ;
286
+ let ret = self . chunk ( ) [ 0 ] ;
287
287
self . advance ( 1 ) ;
288
288
ret
289
289
}
@@ -306,7 +306,7 @@ pub trait Buf {
306
306
/// This function panics if there is no more remaining data in `self`.
307
307
fn get_i8 ( & mut self ) -> i8 {
308
308
assert ! ( self . remaining( ) >= 1 ) ;
309
- let ret = self . bytes ( ) [ 0 ] as i8 ;
309
+ let ret = self . chunk ( ) [ 0 ] as i8 ;
310
310
self . advance ( 1 ) ;
311
311
ret
312
312
}
@@ -861,7 +861,7 @@ pub trait Buf {
861
861
/// let mut chain = b"hello "[..].chain(&b"world"[..]);
862
862
///
863
863
/// let full = chain.copy_to_bytes(11);
864
- /// assert_eq!(full.bytes (), b"hello world");
864
+ /// assert_eq!(full.chunk (), b"hello world");
865
865
/// ```
866
866
fn chain < U : Buf > ( self , next : U ) -> Chain < Self , U >
867
867
where
@@ -908,13 +908,13 @@ macro_rules! deref_forward_buf {
908
908
( * * self ) . remaining( )
909
909
}
910
910
911
- fn bytes ( & self ) -> & [ u8 ] {
912
- ( * * self ) . bytes ( )
911
+ fn chunk ( & self ) -> & [ u8 ] {
912
+ ( * * self ) . chunk ( )
913
913
}
914
914
915
915
#[ cfg( feature = "std" ) ]
916
- fn bytes_vectored <' b>( & ' b self , dst: & mut [ IoSlice <' b>] ) -> usize {
917
- ( * * self ) . bytes_vectored ( dst)
916
+ fn chunks_vectored <' b>( & ' b self , dst: & mut [ IoSlice <' b>] ) -> usize {
917
+ ( * * self ) . chunks_vectored ( dst)
918
918
}
919
919
920
920
fn advance( & mut self , cnt: usize ) {
@@ -1022,7 +1022,7 @@ impl Buf for &[u8] {
1022
1022
}
1023
1023
1024
1024
#[ inline]
1025
- fn bytes ( & self ) -> & [ u8 ] {
1025
+ fn chunk ( & self ) -> & [ u8 ] {
1026
1026
self
1027
1027
}
1028
1028
@@ -1045,7 +1045,7 @@ impl<T: AsRef<[u8]>> Buf for std::io::Cursor<T> {
1045
1045
len - pos as usize
1046
1046
}
1047
1047
1048
- fn bytes ( & self ) -> & [ u8 ] {
1048
+ fn chunk ( & self ) -> & [ u8 ] {
1049
1049
let len = self . get_ref ( ) . as_ref ( ) . len ( ) ;
1050
1050
let pos = self . position ( ) ;
1051
1051
0 commit comments