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
javy- a re-export of thejavycrate.import_namespace- required to provide an import namespace when the plugin is used to generate dynamically linked modules.initialize_runtime- used to configure the QuickJS runtime with aConfigto add behavior to the createdjavy::Runtime.
§Features
json- enables thejsonfeature in thejavycrate.messagepack- enables themessagepackfeature in thejavycrate.
Re-exports§
pub use javy;
Macros§
- import_
namespace - Create a custom section named
import_namespacewith 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.