pub fn decode_u16(buf: &mut ReadBuf<'_>) -> Result<u16>Expand description
Decode a u16 varint from buf.
§Errors
Error::UnexpectedEofifbufis exhausted before the terminator byte.Error::VarintOverflowif the decoded value exceedsu16::MAXor if more thanMAX_LEN_U16bytes would be consumed.
The cursor is unchanged on error.
§Example
use wire_codec::{varint, ReadBuf};
let mut buf = ReadBuf::new(&[0xFF, 0xFF, 0x03]);
assert_eq!(varint::decode_u16(&mut buf).unwrap(), u16::MAX);