[][src]Struct dusk_tlv::TlvReader

pub struct TlvReader<R> where
    R: Read
{ /* fields omitted */ }
[]

Optionally consumes an implementation of Read, and fetch n payloads in TLV format from it.

The payloads can be fetched either via TlvReader::reader_to_tlv_len, or via the iterator

Methods

impl<R> TlvReader<R> where
    R: Read
[src][]

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

TlvReader constructor

pub fn into_inner(self) -> R[src][]

Consumes self, and return the inner reader

pub fn reader_to_tlv_len(reader: R) -> Result<usize, Error>[src][]

Consumes an implementation of Read, and return the amount of bytes that should be read to fetch the TLV payload.

The function will effectively read the bytes to fetch the length, so the reader will be pointing to the begining of the payload after the call.

pub fn read_slice(reader: R, buf: &mut [u8]) -> Result<usize, Error>[src][]

From an implementation of Read, fetch the type, length and write the value to the provided buf.

pub fn read_list<L: From<Vec<u8>>>(&mut self) -> Result<Vec<L>, Error>[src][]

Read a list of serializable items from the provided reader

Trait Implementations

impl<R> From<R> for TlvReader<R> where
    R: Read
[src][+]

impl<R> Iterator for TlvReader<R> where
    R: Read
[src][+]

type Item = Result<Vec<u8>, Error>

The type of the elements being iterated over.

fn next(&mut self) -> Option<Self::Item>[src][]

Since we are dealing with I/O, the iterator itself is error-prone. Therefore, the item must be a Result.

If the function fails to read the TLV type/length, then it will return None.

If the type/length is successfully read but we have an I/O error, the function will return a [Some(Error)]

Otherwise, the payload of the TLV will be returned

impl<'de, '_, R> Deserializer<'de> for &'_ mut TlvReader<R> where
    R: Read
[src][+]

type Error = Error

The error type that can be returned if some error occurs during deserialization. Read more

impl<'de, R> SeqAccess<'de> for TlvReader<R> where
    R: Read
[src][+]

type Error = Error

The error type that can be returned if some error occurs during deserialization. Read more

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

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

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

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

impl<I> IntoIterator for I where
    I: Iterator
[src][+]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

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

type Error = !

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.

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

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

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