Expand description
§wry-bindgen-core
wry-bindgen-core is the minimal, stable API that wry-bindgen builds on. It exposes typed handles for talking to JavaScript: functions you can call, Rust values you can store and borrow back, and closures you can hand to JavaScript.
use wry_bindgen_core::with_runtime;
// Store a native Rust value and get back an opaque handle...
let handle = with_runtime(|rt| rt.insert_object(Counter::default()));
// ...then borrow it back by handle later.
with_runtime(|rt| {
let mut counter = rt.object::<Counter>(handle);
counter.tick();
});§What it provides
JsFunction<F>— a typed handle to a JavaScript function..call(args)runs the round-trip and returns the typed result.Runtimeandwith_runtime— a typed object store: insert a Rust value for anObjectHandle, borrow it back, or remove it.LazyCell<T>/JsThreadLocal<T>— typed runtime-local JavaScript values, such as the globalwindow.CallbackKey<F>— registers a Rust closure with JavaScript, with Rust-owned, JS-owned, and JS-owned-once policies.Clamped,BatchableResult, andRequireFlush— markers used when encoding arguments and return values.
Most of these are driven by the code wry-bindgen’s macro generates; the object store reached through with_runtime is the part you tend to use directly.
Structs§
- Callback
Key - Clamped
- A wrapper type around slices and vectors for binding
Uint8ClampedArray. - Decode
Error - Decoded
Data - Encoded
Data - JsClass
Member Spec - JsExport
Spec - JsFunction
- A typed JS function that resolves from the active runtime on first use.
- JsFunction
Spec - JsModule
Spec - JsRef
- Lazy
Cell - A runtime-local accessor for lazily initialized JavaScript values.
- Object
Handle - Require
Flush - Runtime
- A handle to the active runtime, scoped to a
with_runtimecall. - Rust
Callback - TypeDef
Enums§
Traits§
Functions§
- with_
runtime - Run
fwith the active runtime.
Type Aliases§
- JsThread
Local - Backwards-compatible name used by generated
thread_local_v2bindings.