pub fn encode_unsigned(value: u64, buf: &mut Vec<u8>)Expand description
Encode an unsigned u64 to VInt bytes
Encoding format (standard Cassandra unsigned VInt):
- 1 byte: 0xxxxxxx (values 0-127)
- 2 bytes: 10xxxxxx xxxxxxxx (values 128-16383, 14 bits total: 6+8)
- 3 bytes: 110xxxxx xxxxxxxx xxxxxxxx (values 16384-2097151, 21 bits: 5+8+8)
- … up to 9 bytes total
The first byte encodes the number of extra bytes via leading 1-bits, followed by a 0 separator bit, then data bits.
§Arguments
value- Unsigned 64-bit integer to encodebuf- Target buffer to write VInt bytes
§Examples
let mut buf = Vec::new();
encode_unsigned(0, &mut buf);
assert_eq!(buf, vec![0x00]);
buf.clear();
encode_unsigned(127, &mut buf);
assert_eq!(buf, vec![0x7F]);
buf.clear();
encode_unsigned(128, &mut buf);
assert_eq!(buf, vec![0x80, 0x80]); // 10xxxxxx xxxxxxxx