| Copyright | (c) 2026 Emily Pillmore |
|---|---|
| License | BSD-style |
| Maintainer | Emily Pillmore <emilypi@cohomolo.gy> |
| Stability | Experimental |
| Portability | portable |
| Safe Haskell | None |
| Language | Haskell2010 |
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
- encodePrefix :: Ptr Word8 -> Int -> Ptr Word8 -> IO Int
- decodePrefix :: Ptr Word8 -> Int -> Ptr Word8 -> IO Int
- encodeByteArrayPrefix :: ByteArray -> Int -> MutableByteArray s -> ST s Int
- decodeByteArrayPrefix :: ByteArray -> Int -> MutableByteArray s -> ST s Int
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.