Embedding V8 in Rust
Written
- This is based on using
deno_corebut a lot of it applies directly to usingrusty_v8as well, which maps somewhat to the C++ V8 API. - Other references on embedding V8
- While using rusty_v8, you'll need to use scopes, isolates, locals and globals. This can seem confusing at first, especially when you need to get a local from a global, or when you need a scope and an isolate, but need to take mutable borrows on the engine for both at the same time.
HandleScopederefs toIsolate, so you only need to explicitly get the scope fromruntime.handle_scope(), and then can use it as an isolate as well.- Converting a
Global<Value>to aLocal<Value>-
let = ; let = v8::Local::new; - This is useful with
serde_v8, which simplifies a lot of conversion between JS types and Rust types but needs aLocal.
-