wasmedge-hs-0.17.1.0: Haskell bindings for the WasmEdge WebAssembly runtime
Copyright(c) 2026 Tushar Adhatrao
LicenseMIT
Stabilityinternal
Safe HaskellNone
LanguageGHC2021

WasmEdge.Internal.Utils

Description

Do not import this module in user code.

Synopsis

Text / String conversion

withWasmString :: Text -> (Ptr CString_ -> IO a) -> IO a #

Convert a Haskell Text to a WasmEdge_String (on the stack), call the action, then delete the string.

fromWasmString :: Ptr CString_ -> IO Text #

Alias for peekWasmString — reads a WasmEdge_String and returns Text.

peekWasmString :: Ptr CString_ -> IO Text #

Peek a WasmEdge_String (by pointer) and convert to Haskell Text. Does NOT free the string.

withWasmBytes :: ByteString -> (Ptr CBytes_ -> IO a) -> IO a #

Wrap a ByteString as a stack-allocated WasmEdge_Bytes (zero copy), call the action, and return its result.

Checked result conversion

checkResult :: Ptr CResult_ -> IO (Either WasmEdgeError ()) #

Check a WasmEdge_Result pointer and return 'Right ()' on success or 'Left WasmEdgeError' on failure.

throwOnFail :: Ptr CResult_ -> IO () #

Like checkResult, but throws WasmEdgeError on failure.

Pointer utilities

maybeNullPtr :: Maybe (Ptr t) -> Ptr t #

Convert a 'Maybe (Ptr t)' to a nullable C pointer.

fromNullablePtr :: Ptr t -> Maybe (Ptr t) #

Convert a nullable C pointer to Maybe.