Trait pb_jelly::PbBuffer

source ·
pub trait PbBuffer: Any + Sized {
    // Required methods
    fn len(&self) -> usize;
    fn copy_to_writer<W: Write + ?Sized>(&self, writer: &mut W) -> Result<()>;
    fn copy_from_reader<B: Buf + ?Sized>(reader: &mut B) -> Result<Self>;
}
Expand description

A stand-in trait for any backing buffer store. PbBuffers are expected to own references to the data they reference, and should be cheap (constant-time) to clone.

Required Methods§

source

fn len(&self) -> usize

Returns the length of the data contained in this buffer.

source

fn copy_to_writer<W: Write + ?Sized>(&self, writer: &mut W) -> Result<()>

Fallback method to read the contents of self. This method is expected to write exactly self.len() bytes into writer, or fail with an error.

This method is used to write Lazy fields to incompatible PbBufferWriters.

source

fn copy_from_reader<B: Buf + ?Sized>(reader: &mut B) -> Result<Self>

Fallback method to create an instance of this PbBuffer.

This method is used to read Lazy fields from incompatible PbBufferReaders.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl PbBuffer for Bytes

source§

fn len(&self) -> usize

source§

fn copy_to_writer<W: Write + ?Sized>(&self, writer: &mut W) -> Result<()>

source§

fn copy_from_reader<B: Buf + ?Sized>(reader: &mut B) -> Result<Self>

Implementors§