Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Signed LEB128 codec. This codec encodes the two's complement of a signed number as described here.
Any getXXX decoder can decode bytes generated using any of the putXXX encoders, provided the encoded number fits in the target type.
WARNING: This is not compatible with the Unsigned LEB128 codec at Data.Binary.ULEB128 nor with the ZigZag LEB128 codec at Data.Binary.ZLEB128.
Synopsis
- newtype SLEB128 x = SLEB128 x
- putInteger :: Integer -> Put
- putInt64 :: Int64 -> Put
- putInt32 :: Int32 -> Put
- putInt16 :: Int16 -> Put
- putInt8 :: Int8 -> Put
- putInt :: Int -> Put
- putNatural :: Natural -> Put
- putWord64 :: Word64 -> Put
- putWord32 :: Word32 -> Put
- putWord16 :: Word16 -> Put
- putWord8 :: Word8 -> Put
- putWord :: Word -> Put
- getInteger :: Int -> Get Integer
- getInt64 :: Get Int64
- getInt32 :: Get Int32
- getInt16 :: Get Int16
- getInt8 :: Get Int8
- getInt :: Get Int
- getNatural :: Int -> Get Natural
- getWord64 :: Get Word64
- getWord32 :: Get Word32
- getWord16 :: Get Word16
- getWord8 :: Get Word8
- getWord :: Get Word
- putScientific :: Scientific -> Put
- getScientific :: Int -> Get Scientific
- putRational :: Rational -> Put
- getRational :: Int -> Get Rational
- putFixed :: HasResolution r => Fixed r -> Put
- getFixed :: HasResolution r => Int -> Get (Fixed r)
Documentation
Newtype wrapper for Binary
encoding and decoding x
using the
Signed LEB128 codec. Useful in conjunction with DerivingVia
.
SLEB128 x |
Instances
Binary (SLEB128 Int16) Source # | |
Binary (SLEB128 Int32) Source # | |
Binary (SLEB128 Int64) Source # | |
Binary (SLEB128 Int8) Source # | |
Binary (SLEB128 Word16) Source # | |
Binary (SLEB128 Word32) Source # | |
Binary (SLEB128 Word64) Source # | |
Binary (SLEB128 Word8) Source # | |
Binary (SLEB128 Integer) Source # | Note: Maximum allowed number of input bytes is restricted to 1000.
Use |
Binary (SLEB128 Natural) Source # | Note: Maximum allowed number of input bytes is restricted to 1000.
Use |
Binary (SLEB128 Int) Source # | |
Binary (SLEB128 Word) Source # | |
Put
putInteger :: Integer -> Put Source #
putNatural :: Natural -> Put Source #
Get
Extras
Scientific
putScientific :: Scientific -> Put Source #
Compact Scientific
encoding. Internally, it uses both ULEB128 and
SLEB128. 0 is encoded as \x00
, other numbers take at least two bytes.
Compatible decoders are getFixed
and getScientific
.
:: Int | Maximum number of ULEB128 bytes to consume for the |
-> Get Scientific |
Decode a Scientific
encoded with putScientific
or putFixed
.
Rational
putRational :: Rational -> Put Source #
Compact Rational
encoding. Internally, it uses both ULEB128 and SLEB128.
Decode with getRational
. 0 is encoded as \x00
, other numbers take at
least four bytes.
:: Int | Maximum number of bytes to consume for each of the numerator and
denominator parts. See |
-> Get Rational |
Decode a Rational
encoded with putRational
.
Fixed
putFixed :: HasResolution r => Fixed r -> Put Source #
Same encoding as putScientific
.
Compatible decoders are getFixed
and getScientific
.
:: HasResolution r | |
=> Int | Maximum number of ULEB128 bytes to consume for the |
-> Get (Fixed r) |
Decode a Fixed
encoded with putFixed
or putScientific
.