package extism-manifest

  1. Overview
  2. Docs
On This Page
  1. Examples
  2. API
Legend:
Library
Module
Module type
Parameter
Class
Class type

Extism manifest

This package provides an OCaml interface for the Extism manifest

Examples

Create a manifest from a file on disk:

Manifest.create [ Manifest.Wasm.file myPath ]

Or from a URL:

Manifest.create [ Manifest.Wasm.url myUrl ]

Create a manifest from a file on disk with a timeout of 1s set and memory.max_pages set to 100:

Manifest.create ~timeout_ms:1000 [ Manifest.Wasm.file ]
|> Manifest.with_memory_max 100

API

type memory_options = {
  1. max_pages : int option;
    (*

    max_pages can be used to limit the total number of pages used by the runtime

    *)
}

Memory options

val yojson_of_memory_options : memory_options -> Ppx_yojson_conv_lib.Yojson.Safe.t
val memory_options_of_yojson : Ppx_yojson_conv_lib.Yojson.Safe.t -> memory_options
type dict = (string * string) list

Key/value dictionary

val yojson_of_dict : dict -> Ppx_yojson_conv_lib.Yojson.Safe.t
val dict_of_yojson : Ppx_yojson_conv_lib.Yojson.Safe.t -> dict
type config = (string * string option) list

Key/value dictionary with optional values, used for passing values into a plugin at runtime

val yojson_of_config : config -> Ppx_yojson_conv_lib.Yojson.Safe.t
val config_of_yojson : Ppx_yojson_conv_lib.Yojson.Safe.t -> config
module Wasm : sig ... end
type t = {
  1. wasm : Wasm.t list;
    (*

    A list of Wasm modules to be linked, the final module or the module named main will be used as the main module

    *)
  2. memory : memory_options option;
    (*

    Memory options

    *)
  3. config : config option;
    (*

    Config contains immutable configutation parameters from the host to a plugin

    *)
  4. allowed_hosts : string list option;
    (*

    A list of allowed hosts when using Extism HTTP functions

    *)
  5. allowed_paths : dict option;
    (*

    A dict containing a mapping from local_path:guest_path

    *)
  6. timeout_ms : int option;
    (*

    Plugin timeout in milliseconds

    *)
}

Manifest type

include Ppx_yojson_conv_lib.Yojsonable.S with type t := t
val t_of_yojson : Yojson.Safe.t -> t
val yojson_of_t : t -> Yojson.Safe.t
val create : ?config:config -> ?memory:memory_options -> ?allowed_hosts:string list -> ?allowed_paths:dict -> ?timeout_ms:int -> Wasm.t list -> t

Create new t

val to_json : t -> string

Convert manifest to JSON

val of_json : string -> t

Read manifest from JSON string

val of_file : string -> t

Read manifest from JSON file

val with_config : config -> t -> t

Returns a new t with the config field updated

val with_memory_max : int -> t -> t

Returns a new t with memory.max_pages updates

OCaml

Innovation. Community. Security.