Skip to main content

Module varint

Module varint 

Source
Expand description

Minecraft VarInt encoding and decoding.

VarInts are variable-length 32-bit integers used throughout the Minecraft protocol. Each byte uses 7 bits for data and 1 bit (MSB) as a continuation flag. Values are encoded in little-endian order.

Functionsยง

peek_var_int
Try to read a VarInt from a byte slice without consuming it. Returns Ok(Some((value, bytes_read))) on success, Ok(None) if not enough data is available, or Err if the VarInt is malformed.
read_var_int
Read a VarInt from a Buf, returning the decoded i32.
var_int_bytes
Returns the number of bytes needed to encode a VarInt value.
write_var_int
Write a VarInt to a BufMut.