pub fn decode_u64(buf: &mut ReadBuf<'_>) -> Result<u64>Expand description
Decode a u64 varint from buf.
§Errors
Error::UnexpectedEofifbufis exhausted before the terminator byte.Error::VarintOverflowif more thanMAX_LEN_U64bytes would be consumed or the final byte carries bits that would overflowu64.
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());