Skip to main content

decode_from_slice_with_decoder

Function decode_from_slice_with_decoder 

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

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

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

§Errors

Returns an error if the decoder encounters an error while parsing the data, including insufficient data. This function also errors if the provided slice is not completely consumed during decode.