extism-0.5.0: Extism bindings
Safe HaskellSafe-Inferred
LanguageHaskell2010

Extism

Synopsis

Documentation

type Result a = Either Error a Source #

Result type

newtype Error Source #

Extism error

Constructors

ExtismError String 

Instances

Instances details
Show Error Source # 
Instance details

Defined in Extism

Methods

showsPrec :: Int -> Error -> ShowS #

show :: Error -> String #

showList :: [Error] -> ShowS #

type CurrentPlugin = Ptr ExtismCurrentPlugin Source #

Access the plugin that is currently executing from inside a host function

newtype Context Source #

Context for managing plugins

Constructors

Context (ForeignPtr ExtismContext) 

data Function Source #

Host function

Constructors

Function (ForeignPtr ExtismFunction) (StablePtr ()) 

data Plugin Source #

Plugins can be used to call WASM function

Constructors

Plugin Context Int32 [Function] 

newtype CancelHandle Source #

Cancellation handle for Plugins

Constructors

CancelHandle (Ptr ExtismCancelHandle) 

data LogLevel Source #

Log level

Constructors

Error 
Warn 
Info 
Debug 
Trace 

Instances

Instances details
Show LogLevel Source # 
Instance details

Defined in Extism

free :: Plugin -> IO () Source #

Free a Plugin, this will automatically be called for every plugin | associated with a Context when that Context is freed

reset :: Context -> IO () Source #

Remove all registered plugins in a Context

fromByteString :: ByteString -> String Source #

Helper function to convert a ByteString to a String

update :: Plugin -> ByteString -> [Function] -> Bool -> IO (Result Plugin) Source #

Update a Plugin with a new WASM module

isValid :: Plugin -> Bool Source #

Check if a Plugin is valid

plugin :: Context -> ByteString -> [Function] -> Bool -> IO (Result Plugin) Source #

Create a Plugin from a WASM module, useWasi determines if WASI should | be linked

toByteString :: String -> ByteString Source #

Helper function to convert a String to a ByteString

extismVersion :: () -> IO String Source #

Get the Extism version string

withContext :: (Context -> IO a) -> IO a Source #

Execute a function with a new Context that is destroyed when it returns

withPlugin :: (Plugin -> IO a) -> Plugin -> IO a Source #

Execute a function with the provided Plugin as a parameter, then frees the Plugin | before returning the result.

createPlugin :: ByteString -> [Function] -> Bool -> IO (Result Plugin) Source #

Create a Plugin with its own Context

setConfig :: Plugin -> [(String, Maybe String)] -> IO Bool Source #

Set configuration values for a plugin

setLogFile :: String -> LogLevel -> IO Bool Source #

Set the log file and level, this is a global configuration

functionExists :: Plugin -> String -> IO Bool Source #

Check if a function exists in the given plugin

cancelHandle :: Plugin -> IO CancelHandle Source #

Create a new CancelHandle that can be used to cancel a running plugin | from another thread.

cancel :: CancelHandle -> IO Bool Source #

Cancel a running plugin using a CancelHandle

hostFunction :: String -> [ValType] -> [ValType] -> (CurrentPlugin -> [Val] -> a -> IO [Val]) -> a -> IO Function Source #

Create a new Function that can be called from a Plugin

toI32 :: Integral a => a -> Val Source #

Create a new I32 Val

toI64 :: Integral a => a -> Val Source #

Create a new I64 Val

toF32 :: Float -> Val Source #

Create a new F32 Val

toF64 :: Double -> Val Source #

Create a new F64 Val

fromI32 :: Integral a => Val -> Maybe a Source #

Get I32 Val

fromI64 :: Integral a => Val -> Maybe a Source #

Get I64 Val

data Manifest #

Instances

Instances details
JSON Manifest 
Instance details

Defined in Extism.Manifest

toString :: JSON a => a -> String #

data ValType Source #

Constructors

I32 
I64 
F32 
F64 
V128 
FuncRef 
ExternRef 

Instances

Instances details
Storable ValType Source # 
Instance details

Defined in Extism.Bindings

Show ValType Source # 
Instance details

Defined in Extism.Bindings

Eq ValType Source # 
Instance details

Defined in Extism.Bindings

Methods

(==) :: ValType -> ValType -> Bool #

(/=) :: ValType -> ValType -> Bool #

data Val Source #

Instances

Instances details
Storable Val Source # 
Instance details

Defined in Extism.Bindings

Methods

sizeOf :: Val -> Int #

alignment :: Val -> Int #

peekElemOff :: Ptr Val -> Int -> IO Val #

pokeElemOff :: Ptr Val -> Int -> Val -> IO () #

peekByteOff :: Ptr b -> Int -> IO Val #

pokeByteOff :: Ptr b -> Int -> Val -> IO () #

peek :: Ptr Val -> IO Val #

poke :: Ptr Val -> Val -> IO () #

Show Val Source # 
Instance details

Defined in Extism.Bindings

Methods

showsPrec :: Int -> Val -> ShowS #

show :: Val -> String #

showList :: [Val] -> ShowS #

Eq Val Source # 
Instance details

Defined in Extism.Bindings

Methods

(==) :: Val -> Val -> Bool #

(/=) :: Val -> Val -> Bool #