leb128-binary-0.1.2: Signed and unsigned LEB128 codec for binary library
Safe HaskellSafe-Inferred
LanguageGHC2021

Data.Binary.SLEB128

Contents

Description

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

Documentation

newtype SLEB128 x Source #

Newtype wrapper for Binary encoding and decoding x using the Signed LEB128 codec. Useful in conjunction with DerivingVia.

Constructors

SLEB128 x 

Instances

Instances details
Binary (SLEB128 Int16) Source # 
Instance details

Defined in Data.Binary.SLEB128

Binary (SLEB128 Int32) Source # 
Instance details

Defined in Data.Binary.SLEB128

Binary (SLEB128 Int64) Source # 
Instance details

Defined in Data.Binary.SLEB128

Binary (SLEB128 Int8) Source # 
Instance details

Defined in Data.Binary.SLEB128

Binary (SLEB128 Word16) Source # 
Instance details

Defined in Data.Binary.SLEB128

Binary (SLEB128 Word32) Source # 
Instance details

Defined in Data.Binary.SLEB128

Binary (SLEB128 Word64) Source # 
Instance details

Defined in Data.Binary.SLEB128

Binary (SLEB128 Word8) Source # 
Instance details

Defined in Data.Binary.SLEB128

Binary (SLEB128 Integer) Source #

Note: Maximum allowed number of input bytes is restricted to 1000. Use putNatural if you want a greater limit.

Instance details

Defined in Data.Binary.SLEB128

Binary (SLEB128 Natural) Source #

Note: Maximum allowed number of input bytes is restricted to 1000. Use putNatural if you want a greater limit.

Instance details

Defined in Data.Binary.SLEB128

Binary (SLEB128 Int) Source # 
Instance details

Defined in Data.Binary.SLEB128

Methods

put :: SLEB128 Int -> Put #

get :: Get (SLEB128 Int) #

putList :: [SLEB128 Int] -> Put #

Binary (SLEB128 Word) Source # 
Instance details

Defined in Data.Binary.SLEB128

Put

Get

getInteger Source #

Arguments

:: Int

Maximum number of bytes to consume. If the Integer number can be determined before consuming this number of bytes, it will be. If 0, parsing fails.

Each ULEB128 byte encodes at most 7 bits of data. That is, \(length(encoded) == \lceil\frac{length(data)}{7}\rceil\).

-> Get Integer 

getNatural Source #

Arguments

:: Int

Maximum number of bytes to consume. If the Natural number can be determined before consuming this number of bytes, it will be. If 0, parsing fails.

Each ULEB128 byte encodes at most 7 bits of data. That is, \(length(encoded) == \lceil\frac{length(data)}{7}\rceil\).

-> Get Natural