| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Cardano.Crypto.PinnedSizedBytes
Contents
Synopsis
- data PinnedSizedBytes (n :: Nat)
- psbZero :: KnownNat n => PinnedSizedBytes n
- psbFromBytes :: forall n. KnownNat n => [Word8] -> PinnedSizedBytes n
- psbToBytes :: PinnedSizedBytes n -> [Word8]
- psbFromByteString :: KnownNat n => ByteString -> PinnedSizedBytes n
- psbFromByteStringCheck :: forall n. KnownNat n => ByteString -> Maybe (PinnedSizedBytes n)
- psbToByteString :: PinnedSizedBytes n -> ByteString
- psbUseAsCPtr :: PinnedSizedBytes n -> (Ptr Word8 -> IO r) -> IO r
- psbUseAsSizedPtr :: PinnedSizedBytes n -> (SizedPtr n -> IO r) -> IO r
- psbCreate :: forall n. KnownNat n => (Ptr Word8 -> IO ()) -> IO (PinnedSizedBytes n)
- psbCreateSized :: forall n. KnownNat n => (SizedPtr n -> IO ()) -> IO (PinnedSizedBytes n)
- ptrPsbToSizedPtr :: Ptr (PinnedSizedBytes n) -> SizedPtr n
Documentation
data PinnedSizedBytes (n :: Nat) Source #
n bytes. Storable.
We have two *Bytes types:
PinnedSizedBytesis backed by pinned ByteArray.MLockedSizedBytesis backed by ForeignPtr tomlock-ed memory region.
The ByteString is pinned datatype, but it's represented by
ForeignPtr + offset (and size).
I'm sorry for adding more types for bytes. :(
Instances
Initialization
psbZero :: KnownNat n => PinnedSizedBytes n Source #
Conversions
psbFromBytes :: forall n. KnownNat n => [Word8] -> PinnedSizedBytes n Source #
See instance.IsString (PinnedSizedBytes n)
>>>psbToBytes . (id @(PinnedSizedBytes 4)) . psbFromBytes $ [1,2,3,4][1,2,3,4]
>>>psbToBytes . (id @(PinnedSizedBytes 4)) . psbFromBytes $ [1,2][0,0,1,2]
>>>psbToBytes . (id @(PinnedSizedBytes 4)) . psbFromBytes $ [1,2,3,4,5,6][3,4,5,6]
psbToBytes :: PinnedSizedBytes n -> [Word8] Source #
See psbFromBytes.
psbFromByteString :: KnownNat n => ByteString -> PinnedSizedBytes n Source #
psbFromByteStringCheck :: forall n. KnownNat n => ByteString -> Maybe (PinnedSizedBytes n) Source #
psbToByteString :: PinnedSizedBytes n -> ByteString Source #
C usage
psbUseAsCPtr :: PinnedSizedBytes n -> (Ptr Word8 -> IO r) -> IO r Source #
psbUseAsSizedPtr :: PinnedSizedBytes n -> (SizedPtr n -> IO r) -> IO r Source #
psbCreateSized :: forall n. KnownNat n => (SizedPtr n -> IO ()) -> IO (PinnedSizedBytes n) Source #
ptrPsbToSizedPtr :: Ptr (PinnedSizedBytes n) -> SizedPtr n Source #