pub struct BufferReaderChild<'a, 'b> { /* private fields */ }Expand description
It acts like a copy of a parent BufferReader.
You can create this from BufferReader::child. The child offset will be set
to 0, but its underlying buffer will start from the current parent’s offset.
Having a copy it allows reading the buffer preserving the parent’s original offset.
If you want to commit the number of bytes read to the parent, use BufferReaderChild::commit.
Instead, dropping this without committing, it will not alter the parent.
Implementations§
Source§impl<'a, 'b> BufferReaderChild<'a, 'b>
impl<'a, 'b> BufferReaderChild<'a, 'b>
Sourcepub fn commit(self)
pub fn commit(self)
Advances the parent BufferReader offset of the amount read with this child.
Methods from Deref<Target = BufferReader<'a>>§
Sourcepub fn skip(&mut self, len: usize) -> Result<(), EndOfBuffer>
pub fn skip(&mut self, len: usize) -> Result<(), EndOfBuffer>
Advances the offset.
In case of Err the offset is not advanced.
Sourcepub fn buffer(&self) -> &'a [u8] ⓘ
pub fn buffer(&self) -> &'a [u8] ⓘ
Returns a reference to the internal buffer.
Note: this is the entire buffer (despite offset).
Sourcepub fn buffer_remaining(&mut self) -> &'a [u8] ⓘ
pub fn buffer_remaining(&mut self) -> &'a [u8] ⓘ
Returns the inner buffer starting from the current offset.
Sourcepub fn child(&mut self) -> BufferReaderChild<'a, '_>
pub fn child(&mut self) -> BufferReaderChild<'a, '_>
Creates a BufferReaderChild with this parent.