| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
Raaz.Core.Util
Description
Some useful utility functions and combinators.
- length :: ByteString -> BYTES Int
- replicate :: LengthUnit l => l -> Word8 -> ByteString
- fromByteStringStorable :: Storable k => ByteString -> k
- 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.
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.
Arguments
| :: 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.
Arguments
| :: 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.