-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Extism bindings
--
-- Bindings to Extism, the universal plugin system
@package extism
@version 0.5.0
module Extism
-- | Result type
type Result a = Either Error a
-- | Extism error
newtype Error
ExtismError :: String -> Error
-- | Access the plugin that is currently executing from inside a host
-- function
type CurrentPlugin = Ptr ExtismCurrentPlugin
-- | Context for managing plugins
newtype Context
Context :: ForeignPtr ExtismContext -> Context
-- | Host function
data Function
Function :: ForeignPtr ExtismFunction -> StablePtr () -> Function
-- | Plugins can be used to call WASM function
data Plugin
Plugin :: Context -> Int32 -> [Function] -> Plugin
-- | Cancellation handle for Plugins
newtype CancelHandle
CancelHandle :: Ptr ExtismCancelHandle -> CancelHandle
-- | Log level
data LogLevel
Error :: LogLevel
Warn :: LogLevel
Info :: LogLevel
Debug :: LogLevel
Trace :: LogLevel
-- | Free a Plugin, this will automatically be called for every
-- plugin | associated with a Context when that Context is
-- freed
free :: Plugin -> IO ()
-- | Remove all registered plugins in a Context
reset :: Context -> IO ()
-- | Helper function to convert a ByteString to a String
fromByteString :: ByteString -> String
-- | Update a Plugin with a new WASM module
update :: Plugin -> ByteString -> [Function] -> Bool -> IO (Result Plugin)
-- | Check if a Plugin is valid
isValid :: Plugin -> Bool
-- | Create a Plugin from a WASM module, useWasi determines
-- if WASI should | be linked
plugin :: Context -> ByteString -> [Function] -> Bool -> IO (Result Plugin)
-- | Helper function to convert a String to a ByteString
toByteString :: String -> ByteString
-- | Get the Extism version string
extismVersion :: () -> IO String
-- | Create a new Context
newContext :: IO Context
-- | Execute a function with a new Context that is destroyed when it
-- returns
withContext :: (Context -> IO a) -> IO a
-- | Execute a function with the provided Plugin as a parameter,
-- then frees the Plugin | before returning the result.
withPlugin :: (Plugin -> IO a) -> Plugin -> IO a
-- | Create a Plugin with its own Context
createPlugin :: ByteString -> [Function] -> Bool -> IO (Result Plugin)
-- | Create a Plugin from a Manifest
pluginFromManifest :: Context -> Manifest -> [Function] -> Bool -> IO (Result Plugin)
-- | Create a Plugin with its own Context from a
-- Manifest
createPluginFromManifest :: Manifest -> [Function] -> Bool -> IO (Result Plugin)
-- | Update a Plugin with a new Manifest
updateManifest :: Plugin -> Manifest -> [Function] -> Bool -> IO (Result Plugin)
-- | Set configuration values for a plugin
setConfig :: Plugin -> [(String, Maybe String)] -> IO Bool
levelStr :: LogLevel -> String
-- | Set the log file and level, this is a global configuration
setLogFile :: String -> LogLevel -> IO Bool
-- | Check if a function exists in the given plugin
functionExists :: Plugin -> String -> IO Bool
call :: Plugin -> String -> ByteString -> IO (Result ByteString)
-- | Create a new CancelHandle that can be used to cancel a running
-- plugin | from another thread.
cancelHandle :: Plugin -> IO CancelHandle
-- | Cancel a running plugin using a CancelHandle
cancel :: CancelHandle -> IO Bool
-- | Create a new Function that can be called from a Plugin
hostFunction :: String -> [ValType] -> [ValType] -> (CurrentPlugin -> [Val] -> a -> IO [Val]) -> a -> IO Function
-- | Create a new I32 Val
toI32 :: Integral a => a -> Val
-- | Create a new I64 Val
toI64 :: Integral a => a -> Val
-- | Create a new F32 Val
toF32 :: Float -> Val
-- | Create a new F64 Val
toF64 :: Double -> Val
-- | Get I32 Val
fromI32 :: Integral a => Val -> Maybe a
-- | Get I64 Val
fromI64 :: Integral a => Val -> Maybe a
-- | Get F32 Val
fromF32 :: Val -> Maybe Float
-- | Get F64 Val
fromF64 :: Val -> Maybe Double
data () => Manifest
toString :: JSON a => a -> String
data ValType
I32 :: ValType
I64 :: ValType
F32 :: ValType
F64 :: ValType
V128 :: ValType
FuncRef :: ValType
ExternRef :: ValType
data Val
ValI32 :: Int32 -> Val
ValI64 :: Int64 -> Val
ValF32 :: Float -> Val
ValF64 :: Double -> Val
instance GHC.Show.Show Extism.LogLevel
instance GHC.Show.Show Extism.Error
module Extism.CurrentPlugin
-- | Allocate a new handle of the given size
memoryAlloc :: CurrentPlugin -> Word64 -> IO Word64
-- | Get the length of a handle, returns 0 if the handle is invalid
memoryLength :: CurrentPlugin -> Word64 -> IO Word64
-- | Free allocated memory
memoryFree :: CurrentPlugin -> Word64 -> IO ()
-- | Access a pointer to the entire memory region
memory :: CurrentPlugin -> IO (Ptr Word8)
-- | Access a pointer the a specific offset in memory
memoryOffset :: CurrentPlugin -> Word64 -> IO (Ptr Word8)
-- | Access the data associated with a handle as a ByteString
memoryBytes :: CurrentPlugin -> Word64 -> IO ByteString
-- | Allocate memory and copy an existing ByteString into it
allocBytes :: CurrentPlugin -> ByteString -> IO Word64