[][src]Trait rmpv::decode::value_ref::BorrowRead

pub trait BorrowRead<'a>: Read {
    fn fill_buf(&self) -> &'a [u8];
fn consume(&mut self, len: usize); }

A BorrowRead is a type of Reader which has an internal buffer.

This magic trait acts like a standard BufRead but unlike the standard this has an explicit internal buffer lifetime, which allows to borrow from underlying buffer while consuming bytes.

Required methods

fn fill_buf(&self) -> &'a [u8]

Returns the buffer contents.

This function is a lower-level call. It needs to be paired with the consume method to function properly. When calling this method, none of the contents will be "read" in the sense that later calling read may return the same contents. As such, consume must be called with the number of bytes that are consumed from this buffer to ensure that the bytes are never returned twice.

An empty buffer returned indicates that the stream has reached EOF.

fn consume(&mut self, len: usize)

Tells this buffer that len bytes have been consumed from the buffer, so they should no longer be returned in calls to read.

Loading content...

Implementations on Foreign Types

impl<'a> BorrowRead<'a> for &'a [u8][src]

impl<'a> BorrowRead<'a> for Cursor<&'a [u8]>[src]

Useful when you want to know how much bytes has been consumed during ValueRef decoding.

Loading content...

Implementors

Loading content...