Struct minicbor_io::Reader[][src]

pub struct Reader<R> { /* fields omitted */ }

Wraps a std::io::Read and reads length-delimited CBOR values.

Implementations

impl<R> Reader<R>[src]

pub fn new(reader: R) -> Self[src]

Create a new reader with a max. buffer size of 512KiB.

pub fn with_buffer(reader: R, buffer: Vec<u8>) -> Self[src]

Create a new reader with a max. buffer size of 512KiB.

pub fn set_max_len(&mut self, val: u32)[src]

Set the max. buffer size in bytes.

If length values greater than this are decoded, an Error::InvalidLen will be returned.

pub fn reader(&self) -> &R[src]

Get a reference to the inner reader.

pub fn reader_mut(&mut self) -> &mut R[src]

Get a mutable reference to the inner reader.

pub fn into_parts(self) -> (R, Vec<u8>)[src]

Deconstruct this reader into the inner reader and the buffer.

impl<R: Read> Reader<R>[src]

pub fn read<'a, T: Decode<'a>>(&'a mut self) -> Result<Option<T>, Error>[src]

Read the next CBOR value and decode it.

The value is assumed to be preceded by a u32 (4 bytes in network byte order) denoting the length of the CBOR item in bytes.

Reading 0 bytes when decoding the length prefix results in Ok(None), otherwise either Some value or an error is returned.

Trait Implementations

impl<R: Debug> Debug for Reader<R>[src]

Auto Trait Implementations

impl<R> RefUnwindSafe for Reader<R> where
    R: RefUnwindSafe

impl<R> Send for Reader<R> where
    R: Send

impl<R> Sync for Reader<R> where
    R: Sync

impl<R> Unpin for Reader<R> where
    R: Unpin

impl<R> UnwindSafe for Reader<R> where
    R: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.