package extism

  1. Overview
  2. Docs

Module Extism.Host_functionSource

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

Sourcetype t

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

Sourceval params : t -> Val.Array.t

Get host function parameters array

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

param plugin n returns the nth param from plugin

Sourceval results : t -> Val.Array.t

Get host function results array

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

result plugin n returns the nth result from plugin

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

set_result plugin n v updates the nth result to v

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

Represents a block of guest memory

Sourceval 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

Sourceval 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

Sourceval 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

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

Load a parameter directly from memory

Sourceval 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

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

Similar to input_exn but raises an exception

Sourceval 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

Sourceval host_context : t -> 'a option

Get configured host context

Sourcemodule Memory_handle : sig ... end

Some helpter functions for reading/writing memory

OCaml

Innovation. Community. Security.