Crate javy_plugin_api

Source
Expand description

A crate for creating Javy plugins

Example usage:

use javy_plugin_api::import_namespace;
use javy_plugin_api::Config;

// Dynamically linked modules will use `my_javy_plugin_v1` as the import
// namespace.
import_namespace!("my_javy_plugin_v1");

#[export_name = "initialize_runtime"]
pub extern "C" fn initialize_runtime() {
   let mut config = Config::default();
   config
       .text_encoding(true)
       .javy_stream_io(true);

   javy_plugin_api::initialize_runtime(config, |runtime| runtime).unwrap();
}

The crate will automatically add exports for a number of Wasm functions in your crate that Javy needs to work.

§Core concepts

§Features

  • json - enables the json feature in the javy crate.
  • messagepack - enables the messagepack feature in the javy crate.

Re-exports§

pub use javy;

Macros§

import_namespace
Create a custom section named import_namespace with the contents of the string argument.

Structs§

Config
A configuration for the Javy plugin API.

Functions§

compile_src
Compiles JS source code to QuickJS bytecode.
initialize_runtime
Initializes the Javy runtime.
invoke
Evaluates QuickJS bytecode and optionally invokes exported JS function with name.
run_bytecode
Evaluate the given bytecode.