Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Extism.PDK.Memory implements a low-level interface for interacting with Extism memory
Synopsis
- data Memory = Memory MemoryOffset MemoryLength
- type MemoryOffset = Word64
- type MemoryLength = Word64
- class FromBytes a where
- fromBytes :: ByteString -> Either String a
- class ToBytes a where
- toBytes :: a -> ByteString
- newtype JSON a = JSON a
- newtype MsgPack a = MsgPack a
- load :: FromBytes a => Memory -> IO (Either String a)
- loadString :: Memory -> IO String
- loadByteString :: Memory -> IO ByteString
- outputMemory :: Memory -> IO ()
- memAlloc :: Int -> IO Memory
- free :: Memory -> IO ()
- alloc :: ToBytes a => a -> IO Memory
- allocString :: String -> IO Memory
- allocByteString :: ByteString -> IO Memory
- memoryOffset :: Memory -> MemoryOffset
- memoryLength :: Memory -> MemoryLength
- findMemory :: MemoryOffset -> IO Memory
Documentation
Represents a block of memory by offset and length
type MemoryOffset = Word64 Source #
Offset in Extism memory
type MemoryLength = Word64 Source #
Length of allocated block of memory
class FromBytes a where Source #
A class used to convert values from bytes read from linear memory
Instances
FromBytes Int32 Source # | |
Defined in Extism.PDK.Memory | |
FromBytes Int64 Source # | |
Defined in Extism.PDK.Memory | |
FromBytes Word32 Source # | |
Defined in Extism.PDK.Memory | |
FromBytes Word64 Source # | |
Defined in Extism.PDK.Memory | |
FromBytes ByteString Source # | |
Defined in Extism.PDK.Memory fromBytes :: ByteString -> Either String ByteString Source # | |
FromBytes String Source # | |
Defined in Extism.PDK.Memory | |
FromBytes Double Source # | |
Defined in Extism.PDK.Memory | |
FromBytes Float Source # | |
Defined in Extism.PDK.Memory | |
Data a => FromBytes (JSON a) Source # | |
Defined in Extism.PDK.Memory | |
MsgPack a => FromBytes (MsgPack a) Source # | |
Defined in Extism.PDK.Memory |
class ToBytes a where Source #
A class used to convert values to bytes to be written into linear memory
toBytes :: a -> ByteString Source #
Instances
ToBytes Int32 Source # | |
Defined in Extism.PDK.Memory toBytes :: Int32 -> ByteString Source # | |
ToBytes Int64 Source # | |
Defined in Extism.PDK.Memory toBytes :: Int64 -> ByteString Source # | |
ToBytes Word32 Source # | |
Defined in Extism.PDK.Memory toBytes :: Word32 -> ByteString Source # | |
ToBytes Word64 Source # | |
Defined in Extism.PDK.Memory toBytes :: Word64 -> ByteString Source # | |
ToBytes ByteString Source # | |
Defined in Extism.PDK.Memory toBytes :: ByteString -> ByteString Source # | |
ToBytes String Source # | |
Defined in Extism.PDK.Memory toBytes :: String -> ByteString Source # | |
ToBytes Double Source # | |
Defined in Extism.PDK.Memory toBytes :: Double -> ByteString Source # | |
ToBytes Float Source # | |
Defined in Extism.PDK.Memory toBytes :: Float -> ByteString Source # | |
Data a => ToBytes (JSON a) Source # | |
Defined in Extism.PDK.Memory toBytes :: JSON a -> ByteString Source # | |
MsgPack a => ToBytes (MsgPack a) Source # | |
Defined in Extism.PDK.Memory toBytes :: MsgPack a -> ByteString Source # |
A wrapper type for JSON encoded values
JSON a |
A wrapper type for MsgPack encoded values
MsgPack a |
loadByteString :: Memory -> IO ByteString Source #
Load ByteString from Memory
block
alloc :: ToBytes a => a -> IO Memory Source #
Encode a value and copy it into Extism memory, returning the Memory block
allocByteString :: ByteString -> IO Memory Source #
Allocate a new Memory
block and copy the encoded value
memoryOffset :: Memory -> MemoryOffset Source #
Get the offset of a Memory
block
memoryLength :: Memory -> MemoryLength Source #
Get the length of a Memory
block
findMemory :: MemoryOffset -> IO Memory Source #
Find Memory
block by offset