| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Extism.PDK.Memory
Description
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 JSONValue a = JSONValue a
- newtype MsgPackValue a = MsgPackValue 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
Constructors
| Memory MemoryOffset MemoryLength |
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 Methods 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 | |
| JSON a => FromBytes (JSONValue a) Source # | |
Defined in Extism.PDK.Memory | |
| MsgPack a => FromBytes (MsgPackValue a) Source # | |
Defined in Extism.PDK.Memory Methods fromBytes :: ByteString -> Either String (MsgPackValue a) Source # | |
class ToBytes a where Source #
A class used to convert values to bytes to be written into linear memory
Methods
toBytes :: a -> ByteString Source #
Instances
A wrapper type for JSON encoded values
Constructors
| JSONValue a |
newtype MsgPackValue a Source #
A wrapper type for MsgPack encoded values
Constructors
| MsgPackValue a |
Instances
| MsgPack a => FromBytes (MsgPackValue a) Source # | |
Defined in Extism.PDK.Memory Methods fromBytes :: ByteString -> Either String (MsgPackValue a) Source # | |
| MsgPack a => ToBytes (MsgPackValue a) Source # | |
Defined in Extism.PDK.Memory Methods toBytes :: MsgPackValue a -> ByteString Source # | |
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