Trait codec::buffer::BufferReader[][src]

pub trait BufferReader {
    fn bytes(&self) -> &[u8];
fn advance(&mut self, count: usize);
fn read_bytes(&mut self, count: usize) -> Result<&[u8]>; }

A trait to provide sequential read over a memory buffer.

The memory buffer can be &[u8] or std::io::Cursor<AsRef<[u8]>>.

Required methods

fn bytes(&self) -> &[u8][src]

Returns a slice starting at current position.

The returned slice can be empty.

fn advance(&mut self, count: usize)[src]

Advances the position of internal cursor.

Panics

This function may panic in some implementors when remaining space is not large enough to advance.

TODO: We should make the panic behaviour deterministic.

fn read_bytes(&mut self, count: usize) -> Result<&[u8]>[src]

Read next several bytes as a slice and advance the position of internal cursor.

Errors

Returns Error::Io if there is not enough space to read specified number of bytes.

Loading content...

Implementations on Foreign Types

impl<T: AsRef<[u8]>> BufferReader for Cursor<T>[src]

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

impl<'a, T: BufferReader + ?Sized> BufferReader for &'a mut T[src]

impl<T: BufferReader + ?Sized> BufferReader for Box<T>[src]

Loading content...

Implementors

Loading content...