pub struct ByteReader<'a> { /* private fields */ }
Expand description

Reader for protobuf messages.

Implementations§

source§

impl<'a> ByteReader<'a>

source

pub fn new(data: &'a [u8]) -> Self

Create a new ByteReader that reads from data.

source

pub fn inner(&self) -> &[u8]

Get a reference to the remaining bytes.

source

pub fn eof(&self) -> bool

Check if the reader is at the end of the buffer.

source

pub fn read<const N: usize>(&mut self) -> Result<[u8; N], ReadError>

Read N bytes from the buffer.

source

pub fn read_u8(&mut self) -> Result<u8, ReadError>

Read a single byte from the buffer.

source

pub fn read_u16(&mut self) -> Result<u16, ReadError>

Read a u16 from the buffer.

source

pub fn read_u32(&mut self) -> Result<u32, ReadError>

Read a u32 from the buffer.

source

pub fn read_u64(&mut self) -> Result<u64, ReadError>

Read a u64 from the buffer.

source

pub fn read_slice(&mut self, len: usize) -> Result<&'a [u8], ReadError>

Read a slice of length len from the buffer.

source

pub fn read_to_end(&mut self) -> Result<&'a [u8], ReadError>

Read the remaining bytes from the buffer.

source

pub fn read_varslice(&mut self) -> Result<&'a [u8], ReadError>

Read a variable length slice from the buffer.

source

pub fn read_varuint_bytes(&mut self) -> Result<&'a [u8], ReadError>

Read varint-encoded bytes from the buffer.

source

pub fn read_varuint32(&mut self) -> Result<u32, ReadError>

Read varint-encoded u32 from the buffer.

source

pub fn read_varint32(&mut self) -> Result<i32, ReadError>

Read a varint-encoded i32 from the buffer.

source

pub fn read_varuint64(&mut self) -> Result<u64, ReadError>

Read a varint-encoded u64 from the buffer.

source

pub fn read_varint64(&mut self) -> Result<i64, ReadError>

Read a varint-encoded i64 from the buffer.

source

pub fn read_fields(&mut self) -> FieldIter<'_, 'a>

Return an iterator over the fields in the buffer.

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for ByteReader<'a>

§

impl<'a> Send for ByteReader<'a>

§

impl<'a> Sync for ByteReader<'a>

§

impl<'a> Unpin for ByteReader<'a>

§

impl<'a> UnwindSafe for ByteReader<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.