Struct Decoder

Source
pub struct Decoder<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> Decoder<'a>

Source

pub fn new(bytes: &'a [u8]) -> Decoder<'a>

Source

pub fn read_byte(&mut self) -> Result<u8, Error>

Source

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

Source

pub fn skip(&mut self, len: usize) -> Result<(), Error>

Source

pub fn back(&mut self, len: usize) -> Result<(), Error>

Source

pub fn pos(&self) -> usize

Source

pub fn len(&self) -> usize

Source

pub fn expect_char(&mut self, expected_char: char) -> Result<(), Error>

Source

pub fn read_sized_field<T>(&mut self, size: usize) -> Result<T, Error>
where T: Decode,

Source

pub fn read_numbered_sized_field<T>( &mut self, number: u8, size: usize, ) -> Result<T, Error>
where T: Decode,

Source

pub fn read_numbered_sized_optional_field<T>( &mut self, number: u8, size: usize, ) -> Result<Option<T>, Error>
where T: Decode,

Source

pub fn read_numbered_field<T>(&mut self, number: u8) -> Result<T, Error>
where T: Decode,

Source

pub fn read_sized_list<T>( &mut self, list_length: usize, item_size: usize, ) -> Result<Vec<T>, Error>
where T: Decode,

Source

pub fn read_list<T>(&mut self, list_length: usize) -> Result<Vec<T>, Error>
where T: Decode,

Trait Implementations§

Source§

impl<'a> Debug for Decoder<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a [u8]> for Decoder<'a>

Source§

fn from(value: &'a [u8]) -> Decoder<'a>

Converts to this type from the input type.
Source§

impl<'a> From<&'a str> for Decoder<'a>

Source§

fn from(value: &'a str) -> Decoder<'a>

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for Decoder<'a>

§

impl<'a> RefUnwindSafe for Decoder<'a>

§

impl<'a> Send for Decoder<'a>

§

impl<'a> Sync for Decoder<'a>

§

impl<'a> Unpin for Decoder<'a>

§

impl<'a> UnwindSafe for Decoder<'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>,

Source§

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>,

Source§

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.