Unsigned Var Int Codec
Unsigned LEB128 variable-length integer codec for UInt — the classic 7-bits-per-byte, high-bit-as-continuation encoding (protobuf varint, DWARF LEB128). A self-delimiting VariableLengthCodec, so it reports Exact(encodedLength) at runtime (no BackPatch) and frames a stream via peekValue.
value range bytes
0 .. 2^7-1 (127) 1
.. 2^14-1 2
.. 2^21-1 3
.. 2^28-1 4
.. 2^32-1 5 (the 5th byte carries only the top 4 bits)Each byte stores 7 value bits (little-endian group order); the high bit (0x80) is set on every byte except the last. Encoding is minimal. Decoding rejects an over-long sequence (a value that cannot fit in UInt, or a 6th continuation byte) with DecodeException so a truncated/malicious stream can never loop or overflow.
This is the library's first shipped self-delimiting integer encoding — used by the generated enum-discriminator codec (a @ProtocolMessage enum field's ordinal rides as an UnsignedVarIntCodec value), and available to consumers via @UseCodec(UnsignedVarIntCodec::class).
Properties
Functions
Bytes value encodes to — always known from the value alone.
Decode the value and its byte length from a stream prefix beginning at baseOffset, without consuming any bytes. Returns VarLenPeek.NeedsMoreData when the prefix is too short to determine either.
Reports the on-wire byte size. Defaults to WireSize.BackPatch.