leb128-binary-0.1.3: 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 

Extras

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.

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.

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.

Text

putText :: Text -> Put Source #

Puts a strict Text, UTF8-encoded with its ULEB128-encoded length as prefix.

See getText.

getText :: Get Text Source #

Gets a strict Text, UTF8-encoded with its ULEB128-encoded length as prefix.

See putText.

putLazyText :: Text -> Put Source #

Puts a lazy Text, UTF8-encoded with its ULEB128-encoded length as prefix.

See getLazyText.

getLazyText :: Get Text Source #

Gets a lazy Text, UTF8-encoded with its ULEB128-encoded length as prefix.

See putLazyText.

List

putList Source #

Arguments

:: (a -> Put)

Encode individual element.

-> [a] 
-> Put 

Elements of the list are prefixed with ULEB128-encoded length. Decode with getList.

getList Source #

Arguments

:: forall a. Get a

Decode individual element.

-> Get [a] 

Decodes a list encoded with putList.

Seq

putSeq Source #

Arguments

:: (a -> Put)

Encode individual element.

-> Seq a 
-> Put 

Elements of the Seq are prefixed with ULEB128-encoded length. Decode with getSeq.

getSeq Source #

Arguments

:: forall a. Get a

Decode individual element.

-> Get (Seq a) 

Decodes a list encoded with putSeq.

Set

putSet Source #

Arguments

:: (a -> Put)

Encode individual element.

-> Set a 
-> Put 

Elements of the Set are prefixed with ULEB128-encoded length. Decode with getSet.

getSet Source #

Arguments

:: forall a. Ord a 
=> Get a

Decode individual element.

-> Get (Set a) 

Decodes a list encoded with putSet.

Map

putMap Source #

Arguments

:: (k -> Put)

Encode individual key.

-> (v -> Put)

Encode individual value.

-> Map k v 
-> Put 

Elements of the Map are prefixed with ULEB128-encoded length. Decode with getMap.

getMap Source #

Arguments

:: forall k v. Ord k 
=> Get k

Decode individual key.

-> Get v

Decode individual value.

-> Get (Map k v) 

Decodes a list encoded with putMap.