@@ -7,6 +7,8 @@ use crate::cmp;
7
7
use crate :: fmt:: { self , Debug , Formatter } ;
8
8
use crate :: mem:: MaybeUninit ;
9
9
10
+ use core:: ops:: Deref ;
11
+
10
12
/// A wrapper around a byte buffer that is incrementally filled and initialized.
11
13
///
12
14
/// This type is a sort of "double cursor". It tracks three regions in the buffer: a region at the beginning of the
@@ -262,32 +264,12 @@ impl<'a, 'b> ReadBufRef<'a, 'b> {
262
264
ReadBufRef { read_buf : self . read_buf }
263
265
}
264
266
265
- /// Returns the total capacity of the buffer.
266
- #[ inline]
267
- pub fn capacity ( & self ) -> usize {
268
- self . read_buf . capacity ( )
269
- }
270
-
271
- /// Returns a shared reference to the filled portion of the buffer.
272
- #[ inline]
273
- pub fn filled ( & self ) -> & [ u8 ] {
274
- self . read_buf . filled ( )
275
- }
276
-
277
267
/// Returns a mutable reference to the filled portion of the buffer.
278
268
#[ inline]
279
269
pub fn filled_mut ( & mut self ) -> & mut [ u8 ] {
280
270
self . read_buf . filled_mut ( )
281
271
}
282
272
283
- /// Returns a shared reference to the initialized portion of the buffer.
284
- ///
285
- /// This includes the filled portion.
286
- #[ inline]
287
- pub fn initialized ( & self ) -> & [ u8 ] {
288
- self . read_buf . initialized ( )
289
- }
290
-
291
273
/// Returns a mutable reference to the initialized portion of the buffer.
292
274
///
293
275
/// This includes the filled portion.
@@ -335,12 +317,6 @@ impl<'a, 'b> ReadBufRef<'a, 'b> {
335
317
self . read_buf . initialize_unfilled_to ( n)
336
318
}
337
319
338
- /// Returns the number of bytes at the end of the slice that have not yet been filled.
339
- #[ inline]
340
- pub fn remaining ( & self ) -> usize {
341
- self . read_buf . remaining ( )
342
- }
343
-
344
320
/// Clears the buffer, resetting the filled region to empty.
345
321
///
346
322
/// The number of initialized bytes is not changed, and the contents of the buffer are not modified.
@@ -398,16 +374,12 @@ impl<'a, 'b> ReadBufRef<'a, 'b> {
398
374
pub fn append ( & mut self , buf : & [ u8 ] ) {
399
375
self . read_buf . append ( buf)
400
376
}
377
+ }
401
378
402
- /// Returns the amount of bytes that have been filled.
403
- #[ inline]
404
- pub fn filled_len ( & self ) -> usize {
405
- self . read_buf . filled_len ( )
406
- }
379
+ impl < ' a , ' b > Deref for ReadBufRef < ' a , ' b > {
380
+ type Target = ReadBuf < ' b > ;
407
381
408
- /// Returns the amount of bytes that have been initialized.
409
- #[ inline]
410
- pub fn initialized_len ( & self ) -> usize {
411
- self . read_buf . initialized_len ( )
382
+ fn deref ( & self ) -> & ReadBuf < ' b > {
383
+ & * self . read_buf
412
384
}
413
385
}
0 commit comments