CborReader

Struct CborReader 

Source
pub struct CborReader<'b, R>
where R: Read,
{ /* private fields */ }

Implementations§

Source§

impl<'b, R: Read> CborReader<'b, R>

Source

pub fn new(source: R, buf: &'b mut [u8]) -> Self

Create a new reader

The provided buf must be sufficiently large to contain what corresponds to one decode item.

Source

pub async fn array<AR: CborArrayReader<()>>( &mut self, array_reader: &mut AR, ) -> Result<usize, Error>
where Self: Sized,

Read an array using a CborArrayReader.

Source

pub async fn array_with<C, AR: CborArrayReader<C>>( &mut self, array_reader: &mut AR, ctx: &mut C, ) -> Result<usize, Error>
where Self: Sized,

Read an array using a CborArrayReader accepting a user provided decoding context.

Source

pub async fn map<MR: CborMapReader<()>>( &mut self, map_reader: &mut MR, ) -> Result<usize, Error>
where Self: Sized,

Read a map using a CborMapReader.

Source

pub async fn map_with<C, MR: CborMapReader<C>>( &mut self, map_reader: &mut MR, ctx: &mut C, ) -> Result<usize, Error>
where Self: Sized,

Read a map using a CborMapReader accepting a user provided decoding context.

Source

pub async fn read<T>(&mut self) -> Result<Option<T>, Error>
where for<'a> T: Decode<'a, ()>,

Read the next CBOR value and decode it

Source

pub async fn read_with<C, T>(&mut self, ctx: &mut C) -> Result<Option<T>, Error>
where for<'a> T: Decode<'a, C>,

Like CborReader::read but accepting a user provided decoding context.

Trait Implementations§

Source§

impl<'b, R> Debug for CborReader<'b, R>
where R: Read + Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'b, R> Freeze for CborReader<'b, R>
where R: Freeze,

§

impl<'b, R> RefUnwindSafe for CborReader<'b, R>
where R: RefUnwindSafe,

§

impl<'b, R> Send for CborReader<'b, R>
where R: Send,

§

impl<'b, R> Sync for CborReader<'b, R>
where R: Sync,

§

impl<'b, R> Unpin for CborReader<'b, R>
where R: Unpin,

§

impl<'b, R> !UnwindSafe for CborReader<'b, R>

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.