[−][src]Crate rusty_v8
Example
use rusty_v8 as v8; let platform = v8::platform::new_default_platform(); v8::V8::initialize_platform(platform); v8::V8::initialize(); let mut create_params = v8::Isolate::create_params(); create_params.set_array_buffer_allocator(v8::new_default_allocator()); let isolate = v8::Isolate::new(create_params); let mut locker = v8::Locker::new(&isolate); { let mut handle_scope = v8::HandleScope::new(&mut locker); let scope = handle_scope.enter(); let mut context = v8::Context::new(scope); context.enter(); let code = v8::String::new(scope, "'Hello' + ' World!'").unwrap(); code.to_rust_string_lossy(scope); let mut script = v8::Script::compile(scope, context, code, None).unwrap(); let result = script.run(scope, context).unwrap(); let result: v8::Local<v8::String> = unsafe { std::mem::transmute_copy(&result) }; let str = result.to_rust_string_lossy(scope); println!("{}", str); context.exit(); } drop(locker);
Modules
V8 | |
array_buffer_view | |
inspector | |
json | A JSON Parser and Stringifier. |
platform | |
scope | |
script_compiler | For compiling scripts. |
Structs
Allocator | A thread-safe allocator that V8 uses to allocate |ArrayBuffer|'s memory. The allocator is a global V8 setting. It has to be set via Isolate::CreateParams. |
ArrayBuffer | An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5). |
BackingStore | A wrapper around the backing store (i.e. the raw memory) of an array buffer. See a document linked in http://crbug.com/v8/9908 for more information. |
Boolean | A primitive boolean value (ECMA-262, 4.3.14). Either the true or false value. |
CallbackScope | |
Context | A sandboxed execution context with its own set of built-in objects and functions. |
CreateParams | Initial configuration parameters for a new Isolate. |
EscapableHandleScope | A HandleScope which first allocates a handle in the current scope which will be later filled with the escape value. |
ExternalReferences | |
Function | A JavaScript function object (ECMA-262, 15.3). |
FunctionCallbackInfo | The argument information given to function call callbacks. This class provides access to information about the context of the call, including the receiver, the number and values of arguments, and the holder of the function. |
FunctionTemplate | A FunctionTemplate is used to create functions at runtime. There can only be one function created from a FunctionTemplate in a context. The lifetime of the created function is equal to the lifetime of the context. So in case the embedder needs to create temporary functions that can be collected using Scripts is preferred. |
Global | An object reference that is independent of any handle scope. Where a Local handle only lives as long as the HandleScope in which it was allocated, a global handle remains valid until it is explicitly disposed using reset(). |
HandleScope | A stack-allocated class that governs a number of local handles. After a handle scope has been created, all local handles will be allocated within that handle scope until either the handle scope is deleted or another handle scope is created. If there is already a handle scope and a new one is created, all allocations will take place in the new handle scope until it is deleted. After that, new handles will again be allocated in the original handle scope. |
Integer | A JavaScript value representing a signed integer. |
Isolate | Isolate represents an isolated instance of the V8 engine. V8 isolates have completely separate states. Objects from one isolate must not be used in other isolates. The embedder can create multiple isolates and use them in parallel in multiple threads. An isolate can be entered by at most one thread at any given time. The Locker/Unlocker API must be used to synchronize. |
Local | An object reference managed by the v8 garbage collector. |
Location | A location in JavaScript source. |
Locker | v8::Locker is a scoped lock object. While it's active, i.e. between its construction and destruction, the current thread is allowed to use the locked isolate. V8 guarantees that an isolate can be locked by at most one thread at any time. In other words, the scope of a v8::Locker is a critical section. |
Message | An error message. |
Module | A compiled JavaScript module. |
Name | A superclass for symbols and strings. |
Number | A JavaScript number value (ECMA-262, 4.3.20) |
Object | A JavaScript object (ECMA-262, 4.3.3) |
OwnedIsolate | Same as Isolate but gets disposed when it goes out of scope. |
Primitive | The superclass of primitive values. See ECMA-262 4.3.2. |
PrimitiveArray | An array to hold Primitive values. This is used by the embedder to pass host defined options to the ScriptOptions during compilation. |
Promise | An instance of the built-in Promise constructor (ES6 draft). |
PromiseRejectMessage | |
PromiseResolver | |
PropertyCallbackInfo | The information passed to a property callback about the context of the property access. |
ReturnValue | |
Script | A compiled JavaScript script, tied to a Context which was active when the script was compiled. |
ScriptOrModule | A container type that holds relevant metadata for module loading. |
ScriptOrigin | The origin, within a file, of a script. |
SharedRef | Wrapper around a C++ shared_ptr. The shared_ptr is assumed to contain a value and not be null. |
SnapshotCreator | Helper class to create a snapshot data blob. |
StackTrace | Representation of a JavaScript stack trace. The information collected is a snapshot of the execution stack and the information remains valid after execution continues. |
StartupData | |
String | A JavaScript string value (ECMA-262, 4.3.17). |
TryCatch | An external exception handler. |
TryCatchScope | A scope object that will, when entered, active the embedded TryCatch block. |
Uint8Array | An instance of Uint8Array constructor (ES6 draft 15.13.6). |
UniqueRef | Pointer to object allocated on the C++ heap. The pointer may not be null. |
Value | The superclass of all JavaScript values and objects. |
Enums
FunctionCodeHandling | |
MaybeBool | |
ModuleStatus | The different states a module can be in. |
NewStringType | |
PromiseRejectEvent | |
PromiseState |
Traits
InIsolate | Trait for retrieving the current isolate from a scope object. |
ToLocal |
Functions
create_message | Creates an error message for the given exception. Will try to reconstruct the original stack trace from the exception value, or capture the current stack trace if not available. |
error | |
get_stack_trace | Returns the original stack trace that was captured at the creation time of a given exception, or an empty handle if not available. |
new_default_allocator | malloc/free based convenience allocator. |
new_false | |
new_null | |
new_true | |
new_undefined | |
range_error | |
reference_error | |
syntax_error | |
type_error |
Type Definitions
HostImportModuleDynamicallyCallback | HostImportModuleDynamicallyCallback is called when we require the embedder to load a module. This is used as part of the dynamic import syntax. |
HostInitializeImportMetaObjectCallback | HostInitializeImportMetaObjectCallback is called the first time import.meta is accessed for a module. Subsequent access will reuse the same value. |
MessageCallback | |
PromiseRejectCallback | |
ResolveCallback | Called during Module::instantiate_module. Provided with arguments:
(context, specifier, referrer)
Return null on error.
Hint: to tranform Local |