Skip to main content

decode_reader

Function decode_reader 

Source
pub async fn decode_reader<R: AsyncRead + Unpin>(
    reader: R,
) -> Result<(u64, usize), DecodeReaderError>
Expand description

Decodes a u64 from a variable-byte-encoded slice.

On success, this function returns Ok with the decoded value and encoding length. Otherwise, the slice data is invalid, and the function returns Err with the corresponding DecodeError giving the reason.

This function expects the encoded value to start at the beginning of the slice; and the slice must be large enough to include all of the encoded bytes of one value. Decoding stops at the end of the encoded value, so it doesn’t matter if the slice is longer.