CborDecoder

Trait CborDecoder 

Source
pub trait CborDecoder {
    type MapDecoder: CborMapDecoder;
    type ArrayDecoder: CborArrayDecoder;

Show 16 methods // Required methods fn decode_tag(&mut self) -> Result<u64, CborSerializationError>; fn decode_positive(self) -> Result<u64, CborSerializationError>; fn decode_negative(self) -> Result<u64, CborSerializationError>; fn decode_map(self) -> Result<Self::MapDecoder, CborSerializationError>; fn decode_array(self) -> Result<Self::ArrayDecoder, CborSerializationError>; fn decode_bytes(self) -> Result<Vec<u8>, CborSerializationError>; fn decode_bytes_exact( self, destination: &mut [u8], ) -> Result<(), CborSerializationError>; fn decode_text(self) -> Result<Vec<u8>, CborSerializationError>; fn decode_simple(self) -> Result<u8, CborSerializationError>; fn decode_float(self) -> Result<f64, CborSerializationError>; fn peek_data_item_header( &mut self, ) -> Result<DataItemHeader, CborSerializationError>; fn skip_data_item(self) -> Result<(), CborSerializationError>; fn options(&self) -> SerializationOptions; // Provided methods fn decode_tag_expect( &mut self, expected_tag: u64, ) -> Result<(), CborSerializationError> { ... } fn decode_map_expect_size( self, expected_size: usize, ) -> Result<Self::MapDecoder, CborSerializationError> where Self: Sized { ... } fn decode_array_expect_size( self, expected_size: usize, ) -> Result<Self::ArrayDecoder, CborSerializationError> where Self: Sized { ... }
}
Expand description

Required Associated Types§

Source

type MapDecoder: CborMapDecoder

Associated map decoder

Source

type ArrayDecoder: CborArrayDecoder

Associated array decoder

Required Methods§

Source

fn decode_tag(&mut self) -> Result<u64, CborSerializationError>

Decode tag data item

Source

fn decode_positive(self) -> Result<u64, CborSerializationError>

Decode positive integer data item

Source

fn decode_negative(self) -> Result<u64, CborSerializationError>

Decode negative integer data item. Notice that the value of the data item is -(negative + 1) where negative is the returned value.

Source

fn decode_map(self) -> Result<Self::MapDecoder, CborSerializationError>

Decode map. Returns a map decoder that must be used to decode the map.

Source

fn decode_array(self) -> Result<Self::ArrayDecoder, CborSerializationError>

Decode array. Returns an array decoder that must be used to decode the array.

Source

fn decode_bytes(self) -> Result<Vec<u8>, CborSerializationError>

Decode bytes.

Source

fn decode_bytes_exact( self, destination: &mut [u8], ) -> Result<(), CborSerializationError>

Decode bytes into given destination. The length of the bytes data item must match the destination length, else an error is returned.

Source

fn decode_text(self) -> Result<Vec<u8>, CborSerializationError>

Decode text and return UTF8 encoding.

Source

fn decode_simple(self) -> Result<u8, CborSerializationError>

Source

fn decode_float(self) -> Result<f64, CborSerializationError>

Source

fn peek_data_item_header( &mut self, ) -> Result<DataItemHeader, CborSerializationError>

Peeks header of next data item to be decoded.

Source

fn skip_data_item(self) -> Result<(), CborSerializationError>

Skips next header and potential content for the data item

Source

fn options(&self) -> SerializationOptions

Serialization options in current context

Provided Methods§

Source

fn decode_tag_expect( &mut self, expected_tag: u64, ) -> Result<(), CborSerializationError>

Decode that and check it equals the given expected_tag

Source

fn decode_map_expect_size( self, expected_size: usize, ) -> Result<Self::MapDecoder, CborSerializationError>
where Self: Sized,

Decode map and check number of entries equals expected_size

Source

fn decode_array_expect_size( self, expected_size: usize, ) -> Result<Self::ArrayDecoder, CborSerializationError>
where Self: Sized,

Decode array and check number of elements equals expected_size

Implementors§

Source§

impl<'a, R> CborDecoder for &'a mut Decoder<R>
where R: Read, <R as Read>::Error: Display,