Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Database.LSMTree.Internal.ByteString
Description
bytestring
extras
Synopsis
- tryCheapToShort :: ByteString -> Either String ShortByteString
- tryGetByteArray :: ByteString -> Either String (ByteArray, Int)
- shortByteStringFromTo :: Int -> Int -> ShortByteString -> Builder
- byteArrayFromTo :: Int -> Int -> ByteArray -> Builder
- byteArrayToByteString :: Int -> Int -> ByteArray -> ByteString
- unsafePinnedByteArrayToByteString :: HasCallStack => Int -> Int -> ByteArray -> ByteString
- byteArrayToSBS :: ByteArray -> ShortByteString
Documentation
tryCheapToShort :: ByteString -> Either String ShortByteString Source #
\( O(1) \) conversion, if possible.
In addition to the conditions explained for tryGetByteArray
, the
bytestring must use the full length of the underlying byte array.
tryGetByteArray :: ByteString -> Either String (ByteArray, Int) Source #
\( O(1) \) conversion from a strict ByteString
to its underlying
pinned ByteArray
, if possible. Also returns the length (in bytes) of the
byte array prefix that was used by the bytestring.
Strict bytestrings are allocated using mallocPlainForeignPtrBytes
, so we
are expecting a PlainPtr
(or FinalPtr
when the length is 0).
We also require that bytestrings referencing a byte array point point at the
beginning, without any offset.
shortByteStringFromTo :: Int -> Int -> ShortByteString -> Builder Source #
Copy of shortByteString
, but with bounds (unchecked).
byteArrayToByteString :: Int -> Int -> ByteArray -> ByteString Source #
\( O(1) \) conversion if the byte array is pinned, \( O(n) \) otherwise. Takes offset and length of the slice to be used.
unsafePinnedByteArrayToByteString :: HasCallStack => Int -> Int -> ByteArray -> ByteString Source #
\( O(1) \) conversion. Takes offset and length of the slice to be used. Fails if the byte array is not pinned.
Based on fromShort
.