Safe Haskell | None |
---|---|
Language | Haskell2010 |
Some useful utility functions and combinators.
- length :: ByteString -> BYTES Int
- replicate :: LengthUnit l => l -> Word8 -> ByteString
- fromByteStringStorable :: Storable k => ByteString -> k
- create :: LengthUnit l => l -> (Pointer -> IO ()) -> IO ByteString
- createFrom :: LengthUnit l => l -> Pointer -> IO ByteString
- withByteString :: ByteString -> (Pointer -> IO a) -> IO a
- unsafeCopyToPointer :: ByteString -> Pointer -> IO ()
- unsafeNCopyToPointer :: LengthUnit n => n -> ByteString -> Pointer -> IO ()
Documentation
replicate :: LengthUnit l => l -> Word8 -> ByteString Source #
A type safe version of replicate
fromByteStringStorable :: Storable k => ByteString -> k Source #
Get the value from the bytestring using peek
.
create :: LengthUnit l => l -> (Pointer -> IO ()) -> IO ByteString Source #
The action create l act
creates a length l
bytestring where
the contents are filled using the the act
to fill the buffer.
createFrom :: LengthUnit l => l -> Pointer -> IO ByteString Source #
The IO action createFrom n cptr
creates a bytestring by copying
n
bytes from the pointer cptr
.
withByteString :: ByteString -> (Pointer -> IO a) -> IO a Source #
Works directly on the pointer associated with the
ByteString
. This function should only read and not modify the
contents of the pointer.
:: ByteString | The source. |
-> Pointer | The destination. |
-> IO () |
Copy the bytestring to the crypto buffer. This operation leads to undefined behaviour if the crypto pointer points to an area smaller than the size of the byte string.
:: LengthUnit n | |
=> n | length of data to be copied |
-> ByteString | The source byte string |
-> Pointer | The buffer |
-> IO () |
Similar to unsafeCopyToPointer
but takes an additional input
n
which is the number of bytes (expressed in type safe length
units) to transfer. This operation leads to undefined behaviour if
either the bytestring is shorter than n
or the crypto pointer
points to an area smaller than n
.