License | BSD3 |
---|---|
Stability | experimental |
Portability | type-families, generalized newtype deriving |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Data.Bytes.VarInt
Description
This module provides a VarInt
wrapper with a Serial
instance
that generates base-128 variable-width ints. Values are encoded 7
bits at a time, with the most significant being a continuation bit.
Thus, the numbers from 0 to 127 require only a single byte to
encode, those from 128 to 16383 require two bytes, etc.
This format is taken from Google's Protocol Buffers, which provides a bit more verbiage on the encoding: https://developers.google.com/protocol-buffers/docs/encoding#varints.