Skip to main content

decode_from_slice_unbounded_with_decoder

Function decode_from_slice_unbounded_with_decoder 

Source
pub fn decode_from_slice_unbounded_with_decoder<D: Decoder + Default>(
    bytes: &mut &[u8],
) -> Result<D::Output, D::Error>
Expand description

Decodes an object from an unbounded byte slice using a Decoder type.

Unlike decode_from_slice_unbounded, this takes a generic Decoder parameter, allowing use with decoders which don’t have a dedicated Decode implementer (e.g. CompactSizeDecoder).

Unlike decode_from_slice_with_decoder, this function will not error if the slice contains additional bytes that are not required to decode. Furthermore, the byte slice reference provided to this function will be updated based on the consumed data, returning the unconsumed bytes.

§Errors

Returns an error if the decoder encounters an error while parsing the data, including insufficient data.