Object Varint
-
- All Implemented Interfaces:
public class VarintObject Varint contains utility functions to encode and decode integers using variable-length quantity (Varint). Varint is a method of serializing integers using one or more bytes; smaller integers use fewer bytes. Used by Multicodec (which is used for DidKey)
-
-
Method Summary
-
-
Method Detail
-
encode
final ByteArray encode(Integer inp)
Encodes the given integer inp into a ByteArray using Varint encoding. The function supports encoding of Integers to Varint byte arrays, which are more efficient in representing smaller numbers using fewer bytes.
- Parameters:
inp- The integer to be encoded.- Returns:
The ByteArray representing inp in Varint format.
-
decode
final Pair<Integer, Integer> decode(ByteArray input)
Decodes the given ByteArray input from Varint format to a Pair of Integers. The function extracts the integer represented by the Varint and the number of bytes read to decode the integer.
- Parameters:
input- The ByteArray to be decoded, representing an integer in Varint format.- Returns:
A Pair where the first element is the decoded integer and the second element is the number of bytes read from input to decode the integer.
-
-
-
-