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

Data.Binary.ULEB128

Description

Unsigned LEB128 codec. This codec encodes an unsigned 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 Signed LEB128 codec at Data.Binary.SLEB128 nor with the ZigZag LEB128 codec at Data.Binary.ZLEB128.

Synopsis

Documentation

newtype ULEB128 x Source #

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

Constructors

ULEB128 x 

Instances

Instances details
(DecodeOnly "getInt16" :: Constraint) => Binary (ULEB128 Int16) Source # 
Instance details

Defined in Data.Binary.ULEB128

(DecodeOnly "getInt32" :: Constraint) => Binary (ULEB128 Int32) Source # 
Instance details

Defined in Data.Binary.ULEB128

(DecodeOnly "getInt64" :: Constraint) => Binary (ULEB128 Int64) Source # 
Instance details

Defined in Data.Binary.ULEB128

(DecodeOnly "getInt8" :: Constraint) => Binary (ULEB128 Int8) Source # 
Instance details

Defined in Data.Binary.ULEB128

Binary (ULEB128 Word16) Source # 
Instance details

Defined in Data.Binary.ULEB128

Binary (ULEB128 Word32) Source # 
Instance details

Defined in Data.Binary.ULEB128

Binary (ULEB128 Word64) Source # 
Instance details

Defined in Data.Binary.ULEB128

Binary (ULEB128 Word8) Source # 
Instance details

Defined in Data.Binary.ULEB128

(DecodeOnly "getInteger" :: Constraint) => Binary (ULEB128 Integer) Source # 
Instance details

Defined in Data.Binary.ULEB128

Binary (ULEB128 Natural) Source #

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

Instance details

Defined in Data.Binary.ULEB128

(DecodeOnly "getInt" :: Constraint) => Binary (ULEB128 Int) Source # 
Instance details

Defined in Data.Binary.ULEB128

Methods

put :: ULEB128 Int -> Put #

get :: Get (ULEB128 Int) #

putList :: [ULEB128 Int] -> Put #

Binary (ULEB128 Word) Source # 
Instance details

Defined in Data.Binary.ULEB128

Put

Get

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 

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 

ByteString

putByteString :: ByteString -> Put Source #

Puts a strict ByteString with its ULEB128-encoded length as prefix.

See getByteString.

getByteString :: Get ByteString Source #

Gets a strict ByteString with its ULEB128-encoded length as prefix.

See putByteString.

Lazy

putLazyByteString :: ByteString -> Put Source #

Puts a lazy ByteString with its ULEB128-encoded length as prefix.

See getLazyByteString.

getLazyByteString :: Get ByteString Source #

Gets a lazy ByteString with its ULEB128-encoded length as prefix.

See putLazyByteString.

Short

putShortByteString :: ShortByteString -> Put Source #

Puts a ShortByteString with its ULEB128-encoded length as prefix.

See getShortByteString.

getShortByteString :: Get ShortByteString Source #

Gets a ShortByteString with its ULEB128-encoded length as prefix.

See putShortByteString.