leb128-binary-0.1.1: Signed and unsigned LEB128 codec for binary library
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Binary.ULEB128

Description

Unsigned LEB128 codec.

Any getXXX decoder can decode bytes generated using any of the putXXX encoders, provided the encoded number fits in the target type.

Synopsis

Put

Get

getNatural Source #

Arguments

:: Word

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

:: Word

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.