Documentation ¶
Overview ¶
Package vint64 implements the vint64 variable length integer encoding
Index ¶
- Constants
- Variables
- func Append(b []byte, v uint64) []byte
- func Decode(b []byte) (v uint64, err error)
- func DecodedLen(b byte) int
- func Encode(b *[MaxLen]byte, v uint64) int
- func EncodedLen(v uint64) int
- func Read(r io.ByteReader) (uint64, error)
- func Unzigzag(v uint64) int64
- func Zigzag(v int64) uint64
Constants ¶
const MaxLen = 9
MaxLen is the maximum number of bytes required to encode an integer.
Variables ¶
var ErrLeadingZeros = errors.New("vint: encoded integer contains leading zeros")
ErrLeadingZeros is returned by Decode when the encoded integer contains unnecessary leading zeros.
Functions ¶
func Append ¶
Append appends the encoding of v to b and returns the resulting slice.
To encode a signed integer, convert the input with Zigzag.
func Decode ¶
Decode parses an integer from b.
The number of bytes read can be determined with DecodedLen.
To decode a signed integer, convert the result with Unzigzag.
func DecodedLen ¶
DecodedLen returns the number of bytes in the encoded integer.
The result will always be in [0, 9].
func Encode ¶
Encode writes v to b, returning the number of bytes written.
To encode a signed integer, convert the input with Zigzag.
func EncodedLen ¶
EncodedLen returns the number of bytes necessary to encode v.
The result will always be in [0, 9].
func Read ¶
func Read(r io.ByteReader) (uint64, error)
Read parses an integer from b.
To decode a signed integer, convert the result with Unzigzag.
Types ¶
This section is empty.