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
Decoder of CBOR. See https://www.rfc-editor.org/rfc/rfc8949.html#section-3
Required Associated Types§
Sourcetype MapDecoder: CborMapDecoder
type MapDecoder: CborMapDecoder
Associated map decoder
Sourcetype ArrayDecoder: CborArrayDecoder
type ArrayDecoder: CborArrayDecoder
Associated array decoder
Required Methods§
Sourcefn decode_tag(&mut self) -> Result<u64, CborSerializationError>
fn decode_tag(&mut self) -> Result<u64, CborSerializationError>
Decode tag data item
Sourcefn decode_positive(self) -> Result<u64, CborSerializationError>
fn decode_positive(self) -> Result<u64, CborSerializationError>
Decode positive integer data item
Sourcefn decode_negative(self) -> Result<u64, CborSerializationError>
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.
Sourcefn decode_map(self) -> Result<Self::MapDecoder, CborSerializationError>
fn decode_map(self) -> Result<Self::MapDecoder, CborSerializationError>
Decode map. Returns a map decoder that must be used to decode the map.
Sourcefn decode_array(self) -> Result<Self::ArrayDecoder, CborSerializationError>
fn decode_array(self) -> Result<Self::ArrayDecoder, CborSerializationError>
Decode array. Returns an array decoder that must be used to decode the array.
Sourcefn decode_bytes(self) -> Result<Vec<u8>, CborSerializationError>
fn decode_bytes(self) -> Result<Vec<u8>, CborSerializationError>
Decode bytes.
Sourcefn decode_bytes_exact(
self,
destination: &mut [u8],
) -> Result<(), CborSerializationError>
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.
Sourcefn decode_text(self) -> Result<Vec<u8>, CborSerializationError>
fn decode_text(self) -> Result<Vec<u8>, CborSerializationError>
Decode text and return UTF8 encoding.
Sourcefn decode_simple(self) -> Result<u8, CborSerializationError>
fn decode_simple(self) -> Result<u8, CborSerializationError>
Decode simple value, see https://www.rfc-editor.org/rfc/rfc8949.html#name-floating-point-numbers-and-
Sourcefn decode_float(self) -> Result<f64, CborSerializationError>
fn decode_float(self) -> Result<f64, CborSerializationError>
Sourcefn peek_data_item_header(
&mut self,
) -> Result<DataItemHeader, CborSerializationError>
fn peek_data_item_header( &mut self, ) -> Result<DataItemHeader, CborSerializationError>
Peeks header of next data item to be decoded.
Sourcefn skip_data_item(self) -> Result<(), CborSerializationError>
fn skip_data_item(self) -> Result<(), CborSerializationError>
Skips next header and potential content for the data item
Sourcefn options(&self) -> SerializationOptions
fn options(&self) -> SerializationOptions
Serialization options in current context
Provided Methods§
Sourcefn decode_tag_expect(
&mut self,
expected_tag: u64,
) -> Result<(), CborSerializationError>
fn decode_tag_expect( &mut self, expected_tag: u64, ) -> Result<(), CborSerializationError>
Decode that and check it equals the given expected_tag
Sourcefn decode_map_expect_size(
self,
expected_size: usize,
) -> Result<Self::MapDecoder, CborSerializationError>where
Self: Sized,
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
Sourcefn decode_array_expect_size(
self,
expected_size: usize,
) -> Result<Self::ArrayDecoder, CborSerializationError>where
Self: Sized,
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