pub trait PbBufferReader: Buf {
    // Required method
    fn split(&mut self, at: usize) -> Self;

    // Provided method
    fn read_buffer<B: PbBuffer>(&mut self) -> Result<B> { ... }
}
Expand description

All concrete types which are used for deserialization should implement PbBufferReader, which includes functions to convert to and from PbBuffer.

Required Methods§

source

fn split(&mut self, at: usize) -> Self

Advance the interal cursor by at, and return a PbBufferReader corresponding to the traversed indices (i.e. self.position..self.position + at).

Provided Methods§

source

fn read_buffer<B: PbBuffer>(&mut self) -> Result<B>

Attempt to read into a compatible PbBuffer, avoiding a copy if possible. The implementation should dispatch on the type B. If unsupported, the reader may fall back to PbBuffer::copy_from_reader.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl PbBufferReader for Cursor<Bytes>

source§

fn read_buffer<B: PbBuffer>(&mut self) -> Result<B>

source§

fn split(&mut self, at: usize) -> Self

source§

impl<'a> PbBufferReader for Cursor<&'a [u8]>

source§

fn split(&mut self, at: usize) -> Self

Implementors§