libp2p-hs-0.1.0.0: Haskell implementation of the libp2p networking stack
Safe HaskellNone
LanguageGHC2021

Network.LibP2P.Core.Varint

Description

Unsigned LEB128 varint encoding/decoding.

Used throughout libp2p for length-prefixed framing, protocol codes, and multiaddr/multihash encoding.

Synopsis

Documentation

encodeUvarint :: Word64 -> ByteString Source #

Encode a Word64 as an unsigned LEB128 varint.

decodeUvarint :: ByteString -> Either String (Word64, ByteString) Source #

Decode an unsigned LEB128 varint from a ByteString. Returns the decoded value and remaining bytes, or an error message.