Skip to main content

decode_u64

Function decode_u64 

Source
pub fn decode_u64(buf: &mut ReadBuf<'_>) -> Result<u64>
Expand description

Decode a u64 varint from buf.

§Errors

The cursor is unchanged on error.

§Example

use wire_codec::{varint, ReadBuf};
let bytes = [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01];
let mut buf = ReadBuf::new(&bytes);
assert_eq!(varint::decode_u64(&mut buf).unwrap(), u64::MAX);
assert!(buf.is_empty());