base16
Copyright(c) 2026 Emily Pillmore
LicenseBSD-style
MaintainerEmily Pillmore <emilypi@cohomolo.gy>
StabilityExperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Data.ByteString.Base16.Internal.SIMD

Description

Bounded vector prefixes for foreign pointers and byte arrays. Pointer callers retain both buffers with withForeignPtr. Byte-array callers pass the arrays directly to unsafe FFI calls, during which GHC cannot run GC; neither pinning nor copying is needed. The kernels retain no pointers and make no Haskell callbacks. Invalid decode blocks are left untouched so scalar tails preserve exact error offsets.

Synopsis

Documentation

encodePrefix :: Ptr Word8 -> Int -> Ptr Word8 -> IO Int Source #

Encode complete blocks; return consumed input bytes and write twice as many bytes. The caller must allocate a sufficiently large output buffer.

decodePrefix :: Ptr Word8 -> Int -> Ptr Word8 -> IO Int Source #

Decode complete valid blocks, returning an even input byte count and writing half as many bytes. Small inputs avoid dispatch/foreign-call cost.

encodeByteArrayPrefix :: ByteArray -> Int -> MutableByteArray s -> ST s Int Source #

Encode a prefix of an immutable byte array into a distinct mutable destination with room for twice the input length. Return consumed bytes. The foreign call only reads the source and writes the destination, so it can be embedded in ST without letting mutable state escape.

decodeByteArrayPrefix :: ByteArray -> Int -> MutableByteArray s -> ST s Int Source #

Decode complete valid blocks into a distinct mutable destination with room for half the input length. Return an even count of consumed bytes.