package extism

  1. Overview
  2. Docs

Host_function represents the plugin that is currently running from inside a host function definition

type t

Opaque type, wraps ExtismCurrentPlugin, this value should never be stored, it is only valid from inside the host function definition

val params : t -> Val.Array.t

Get host function parameters array

val param : t -> int -> Val.t

param plugin n returns the nth param from plugin

val results : t -> Val.Array.t

Get host function results array

val result : t -> int -> Val.t

result plugin n returns the nth result from plugin

val set_result : t -> int -> Val.t -> unit

set_result plugin n v updates the nth result to v

type memory_handle = {
  1. offs : Unsigned.UInt64.t;
  2. len : Unsigned.UInt64.t;
}

Represents a block of guest memory

val output_string : t -> ?index:int -> string -> unit

Return a string from a host function, this copies the string into memory and sets the results array at index with the pointer to the allocated value

val output_bigstring : t -> ?index:int -> Bigstringaf.t -> unit

Return a bigstring from a host function, this copies the bigstring into memory and sets the results array at index with the pointer to the allocated value

val input_string : ?index:int -> t -> string

Get a string argument, the parameter at index should be an int64 value that points to the string in linear memory

val input_bigstring : ?index:int -> t -> Bigstringaf.t

Load a parameter directly from memory

val input : (module Type.S with type t = 'a) -> ?index:int -> t -> ('a, Error.t) result

Get parameter from params array at index and return the converted result

val input_exn : (module Type.S with type t = 'a) -> ?index:int -> t -> 'a

Similar to input_exn but raises an exception

val output : (module Type.S with type t = 'a) -> ?index:int -> t -> 'a -> unit

Convert a value, allocate it and update the results array at index

module Memory_handle : sig ... end

Some helpter functions for reading/writing memory

OCaml

Innovation. Community. Security.