Skip to main content

Decoder

Struct Decoder 

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

Reads values, signature-directed, bounds-checking every access.

Implementations§

Source§

impl<'a> Decoder<'a>

Source

pub fn new(buf: &'a [u8], little_endian: bool) -> Self

Decode a buffer whose position 0 is the alignment origin.

Source

pub fn at(buf: &'a [u8], pos: usize, little_endian: bool) -> Self

Decode starting at pos, keeping the same alignment origin — needed for a header array, whose padding is measured from the start of the message.

Source

pub fn position(&self) -> usize

Source

pub fn remaining(&self) -> usize

Source

pub fn align(&mut self, n: usize) -> Result<(), CodecError>

Source

pub fn byte(&mut self) -> Result<u8, CodecError>

Source

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

Source

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

Source

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

Source

pub fn string(&mut self) -> Result<String, CodecError>

Source

pub fn signature(&mut self) -> Result<String, CodecError>

Source

pub fn value(&mut self, signature: &str) -> Result<Value, CodecError>

Read one value of the type named by signature.

Source

pub fn body(&mut self, signature: &str) -> Result<Vec<Value>, CodecError>

Read a whole message body described by signature.

Auto Trait Implementations§

§

impl<'a> Forget for Decoder<'a>

§

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

§

impl<'a> Move 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> UnsafeUnpin 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.