extism-pdk-1.0.0.0: Extism Plugin Development Kit
Safe HaskellSafe-Inferred
LanguageHaskell2010

Extism.PDK.Memory

Description

Extism.PDK.Memory implements a low-level interface for interacting with Extism memory

Synopsis

Documentation

data Memory Source #

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

Instances details
FromBytes Int32 Source # 
Instance details

Defined in Extism.PDK.Memory

FromBytes Int64 Source # 
Instance details

Defined in Extism.PDK.Memory

FromBytes Word32 Source # 
Instance details

Defined in Extism.PDK.Memory

FromBytes Word64 Source # 
Instance details

Defined in Extism.PDK.Memory

FromBytes ByteString Source # 
Instance details

Defined in Extism.PDK.Memory

FromBytes String Source # 
Instance details

Defined in Extism.PDK.Memory

FromBytes Double Source # 
Instance details

Defined in Extism.PDK.Memory

FromBytes Float Source # 
Instance details

Defined in Extism.PDK.Memory

Data a => FromBytes (JSON a) Source # 
Instance details

Defined in Extism.PDK.Memory

MsgPack a => FromBytes (MsgPack a) Source # 
Instance details

Defined in Extism.PDK.Memory

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

Instances details
ToBytes Int32 Source # 
Instance details

Defined in Extism.PDK.Memory

ToBytes Int64 Source # 
Instance details

Defined in Extism.PDK.Memory

ToBytes Word32 Source # 
Instance details

Defined in Extism.PDK.Memory

ToBytes Word64 Source # 
Instance details

Defined in Extism.PDK.Memory

ToBytes ByteString Source # 
Instance details

Defined in Extism.PDK.Memory

ToBytes String Source # 
Instance details

Defined in Extism.PDK.Memory

ToBytes Double Source # 
Instance details

Defined in Extism.PDK.Memory

ToBytes Float Source # 
Instance details

Defined in Extism.PDK.Memory

Data a => ToBytes (JSON a) Source # 
Instance details

Defined in Extism.PDK.Memory

Methods

toBytes :: JSON a -> ByteString Source #

MsgPack a => ToBytes (MsgPack a) Source # 
Instance details

Defined in Extism.PDK.Memory

newtype JSON a Source #

A wrapper type for JSON encoded values

Constructors

JSON a 

Instances

Instances details
Data a => FromBytes (JSON a) Source # 
Instance details

Defined in Extism.PDK.Memory

Data a => ToBytes (JSON a) Source # 
Instance details

Defined in Extism.PDK.Memory

Methods

toBytes :: JSON a -> ByteString Source #

newtype MsgPack a Source #

A wrapper type for MsgPack encoded values

Constructors

MsgPack a 

Instances

Instances details
MsgPack a => FromBytes (MsgPack a) Source # 
Instance details

Defined in Extism.PDK.Memory

MsgPack a => ToBytes (MsgPack a) Source # 
Instance details

Defined in Extism.PDK.Memory

load :: FromBytes a => Memory -> IO (Either String a) Source #

Load data from Memory block

loadString :: Memory -> IO String Source #

Load string from Memory block

loadByteString :: Memory -> IO ByteString Source #

Load ByteString from Memory block

outputMemory :: Memory -> IO () Source #

Set plugin output to the provided Memory block

memAlloc :: Int -> IO Memory Source #

Allocate a new Memory block

free :: Memory -> IO () Source #

Free a Memory block

alloc :: ToBytes a => a -> IO Memory Source #

Encode a value and copy it into Extism memory, returning the Memory block

allocString :: String -> IO Memory Source #

Allocate a new Memory block and copy the contents of the provided String

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