glue_v8 - V8 Glue for OpenWorkers
Proc-macro crate that generates V8 callback boilerplate from Rust functions.
Usage
use Rc;
// Basic function
// With state from context slot
// With Result (Err throws JS exception)
// With Promise (returns JS Promise)
// Optional parameters
Generated Code
The macro generates a {fn_name}_v8 wrapper function that:
- Extracts arguments from
FunctionCallbackArguments - Converts types using
serde_v8 - Handles V8 Local types directly (Function, Uint8Array, etc.)
- Retrieves state from context slots
- Converts return values back to V8
- Throws exceptions on errors
Supported Types
Parameters:
- Primitives:
i32,u32,f64,bool,String - Optional:
Option<T>(None for undefined/null/missing) - V8 Local types:
v8::Local<v8::Function>,v8::Local<v8::Uint8Array>, etc. - Any type implementing
serde::Deserialize
Return types:
- Primitives and
String Result<T, E>(Err throws exception)- Any type implementing
serde::Serialize
Attributes:
state = Rc<T>- Extract state from context slotpromise- Return a JS Promisename = "jsName"- Custom JS function name
Running Tests