Struct CBORDecoder

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

Implementations§

Source§

impl<'a> CBORDecoder<'a>

Source

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

Source

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

Consume and return n bytes starting at the current position.

Source

pub fn position(&self) -> usize

Source

pub fn finished(&self) -> bool

Source

pub fn ensure_finished(&self) -> Result<(), CBORError>

Source

pub fn remaining_buffer(&self) -> Result<&[u8], CBORError>

Source

pub fn current(&self) -> Result<u8, CBORError>

Get the byte at the current position.

Source

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

Decode a u8 value.

Source

pub fn i8(&mut self) -> Result<i8, CBORError>

Decode an i8 value.

Source

pub fn int_raw(&mut self) -> Result<u8, CBORError>

Get the raw i8 or u8 value.

Source

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

Decode a string slice.

Source

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

Decode a byte slice.

Source

pub fn bytes_sized( &mut self, expected_size: usize, ) -> Result<&'a [u8], CBORError>

Decode a byte slice of an expected size.

Source

pub fn array(&mut self) -> Result<usize, CBORError>

Begin decoding an array.

Source

pub fn map(&mut self) -> Result<usize, CBORError>

Begin decoding a map.

Source

pub fn as_usize(&mut self, b: u8) -> Result<usize, CBORError>

Decode a u8 value into usize.

Source

pub fn type_of(b: u8) -> u8

Get the major type info of the given byte (highest 3 bits).

Source

pub fn info_of(b: u8) -> u8

Get the additionl type info of the given byte (lowest 5 bits).

Source

pub fn is_u8(byte: u8) -> bool

Check for: an unsigned integer encoded as a single byte

Source

pub fn is_i8(byte: u8) -> bool

Check for: a negative integer encoded as a single byte

Source

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

Decode any (supported) CBOR item, but ignore its internal structure and just return the encoded data.

To have bound memory requirements, this depends on the encoded data to be in deterministic encoding, thus not having any indeterminate length items.

Trait Implementations§

Source§

impl<'a> Debug for CBORDecoder<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for CBORDecoder<'a>

§

impl<'a> RefUnwindSafe for CBORDecoder<'a>

§

impl<'a> Send for CBORDecoder<'a>

§

impl<'a> Sync for CBORDecoder<'a>

§

impl<'a> Unpin for CBORDecoder<'a>

§

impl<'a> UnwindSafe for CBORDecoder<'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.