pub struct EscapableHandleScope<'s, 'e: 's, C = Context> { /* private fields */ }
Expand description

A HandleScope which first allocates a handle in the current scope which will be later filled with the escape value.

Implementations§

Pushes the value into the previous scope and returns a handle to it. Cannot be called twice.

Methods from Deref<Target = HandleScope<'s, ()>>§

Returns the context of the currently running JavaScript, or the context on the top of the stack if no JavaScript is running.

Returns either the last context entered through V8’s C++ API, or the context of the currently running microtask while processing microtasks. If a context is entered while executing a microtask, that context is returned.

Schedules an exception to be thrown when returning to JavaScript. When an exception has been scheduled it is illegal to invoke any JavaScript operation; the caller must return immediately and only after the exception has been handled does it become legal to invoke JavaScript operations.

This function always returns the undefined value.

Return data that was previously attached to the isolate snapshot via SnapshotCreator, and removes the reference to it. If called again with same index argument, this function returns DataError::NoData.

The value that was stored in the snapshot must either match or be convertible to type parameter T, otherwise DataError::BadType is returned.

Return data that was previously attached to the context snapshot via SnapshotCreator, and removes the reference to it. If called again with same index argument, this function returns DataError::NoData.

The value that was stored in the snapshot must either match or be convertible to type parameter T, otherwise DataError::BadType is returned.

Methods from Deref<Target = Isolate>§

Retrieve embedder-specific data from the isolate. Returns NULL if SetData has never been called for the given slot.

Associate embedder-specific data with the isolate. slot has to be between 0 and Isolate::get_number_of_data_slots().

Returns the maximum number of available embedder data slots. Valid slots are in the range of 0 <= n < Isolate::get_number_of_data_slots().

Get a reference to embedder data added with set_slot().

Get a mutable reference to embedder data added with set_slot().

Use with Isolate::get_slot and Isolate::get_slot_mut to associate state with an Isolate.

This method gives ownership of value to the Isolate. Exactly one object of each type can be associated with an Isolate. If called more than once with an object of the same type, the earlier version will be dropped and replaced.

Returns true if value was set without replacing an existing value.

The value will be dropped when the isolate is dropped.

Removes the embedder data added with set_slot() and returns it if it exists.

Sets this isolate as the entered one for the current thread. Saves the previously entered one (if any), so that it can be restored when exiting. Re-entering an isolate is allowed.

rusty_v8 note: Unlike in the C++ API, the isolate is entered when it is constructed and exited when dropped.

Exits this isolate by restoring the previously entered one in the current thread. The isolate may still stay the same, if it was entered more than once.

Requires: self == Isolate::GetCurrent().

rusty_v8 note: Unlike in the C++ API, the isolate is entered when it is constructed and exited when dropped.

Clears the set of objects held strongly by the heap. This set of objects are originally built when a WeakRef is created or successfully dereferenced.

This is invoked automatically after microtasks are run. See MicrotasksPolicy for when microtasks are run.

This needs to be manually invoked only if the embedder is manually running microtasks via a custom MicrotaskQueue class’s PerformCheckpoint. In that case, it is the embedder’s responsibility to make this call at a time which does not interrupt synchronous ECMAScript code execution.

Optional notification that the system is running low on memory. V8 uses these notifications to attempt to free memory.

Get statistics about the heap memory usage.

Tells V8 to capture current stack trace when uncaught exception occurs and report it to the message listeners. The option is off by default.

Adds a message listener (errors only).

The same message listener can be added more than once and in that case it will be called more than once for each message.

The exception object will be passed to the callback.

This specifies the callback called when the stack property of Error is accessed.

PrepareStackTraceCallback is called when the stack property of an error is first accessed. The return value will be used as the stack value. If this callback is registed, the |Error.prepareStackTrace| API will be disabled. |sites| is an array of call sites, specified in https://v8.dev/docs/stack-trace-api

Set the PromiseHook callback for various promise lifecycle events.

Set callback to notify about promise reject with no handler, or revocation of such a previous notification once the handler is added.

This specifies the callback called by the upcoming importa.meta language feature to retrieve host-defined meta data for a module.

This specifies the callback called by the upcoming dynamic import() language feature to load modules.

This specifies the callback called by the upcoming ShadowRealm construction language feature to retrieve host created globals.

Add a callback to invoke in case the heap size is close to the heap limit. If multiple callbacks are added, only the most recently added callback is invoked.

Remove the given callback and restore the heap limit to the given limit. If the given limit is zero, then it is ignored. If the current heap size is greater than the given limit, then the heap limit is restored to the minimal limit that is possible for the current heap size.

Adjusts the amount of registered external memory. Used to give V8 an indication of the amount of externally allocated memory that is kept alive by JavaScript objects. V8 uses this to decide when to perform global garbage collections. Registering externally allocated memory will trigger global garbage collections more often than it would otherwise in an attempt to garbage collect the JavaScript objects that keep the externally allocated memory alive.

Returns the policy controlling how Microtasks are invoked.

Returns the policy controlling how Microtasks are invoked.

Runs the default MicrotaskQueue until it gets empty and perform other microtask checkpoint steps, such as calling ClearKeptObjects. Asserts that the MicrotasksPolicy is not kScoped. Any exceptions thrown by microtask callbacks are swallowed.

👎Deprecated: Use Isolate::perform_microtask_checkpoint() instead

An alias for PerformMicrotaskCheckpoint.

Enqueues the callback to the default MicrotaskQueue

Set whether calling Atomics.wait (a function that may block) is allowed in this isolate. This can also be configured via CreateParams::allow_atomics_wait.

Embedder injection point for WebAssembly.compileStreaming(source). The expectation is that the embedder sets it at most once.

The callback receives the source argument (string, Promise, etc.) and an instance of WasmStreaming. The WasmStreaming instance can outlive the callback and is used to feed data chunks to V8 asynchronously.

Returns true if there is ongoing background work within V8 that will eventually post a foreground task, like asynchronous WebAssembly compilation.

Take a heap snapshot. The callback is invoked one or more times with byte slices containing the snapshot serialized as JSON. It’s the callback’s responsibility to reassemble them into a single document, e.g., by writing them to a file. Note that Chrome DevTools refuses to load snapshots without a .heapsnapshot suffix.

Set the default context to be included in the snapshot blob. The snapshot will not contain the global proxy, and we expect one or a global object template to create one, to be provided upon deserialization.

Panics

Panics if the isolate was not created using Isolate::snapshot_creator

Add additional context to be included in the snapshot blob. The snapshot will include the global proxy.

Returns the index of the context in the snapshot blob.

Panics

Panics if the isolate was not created using Isolate::snapshot_creator

Attach arbitrary v8::Data to the isolate snapshot, which can be retrieved via HandleScope::get_context_data_from_snapshot_once() after deserialization. This data does not survive when a new snapshot is created from an existing snapshot.

Panics

Panics if the isolate was not created using Isolate::snapshot_creator

Attach arbitrary v8::Data to the context snapshot, which can be retrieved via HandleScope::get_context_data_from_snapshot_once() after deserialization. This data does not survive when a new snapshot is created from an existing snapshot.

Panics

Panics if the isolate was not created using Isolate::snapshot_creator

Trait Implementations§

Converts this type into a mutable reference of the (usually inferred) input type.
Converts this type into a mutable reference of the (usually inferred) input type.
Converts this type into a mutable reference of the (usually inferred) input type.
Converts this type into a mutable reference of the (usually inferred) input type.
Converts this type into a mutable reference of the (usually inferred) input type.
Converts this type into a mutable reference of the (usually inferred) input type.
Converts this type into a mutable reference of the (usually inferred) input type.
Converts this type into a mutable reference of the (usually inferred) input type.
Converts this type into a mutable reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Dereferences the value.
The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.
Mutably dereferences the value.
Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.