Struct v8::CallbackScope[][src]

pub struct CallbackScope<'s, C = Context> { /* fields omitted */ }
Expand description

A CallbackScope can be used to bootstrap a HandleScope and ContextScope inside a callback function that gets called by V8. Bootstrapping a scope inside a callback is the only valid use case of this type; using it in other places leads to undefined behavior, which is also the reason CallbackScope::new() is marked as being an unsafe function.

For some callback types, rusty_v8 internally creates a scope and passes it as an argument to to embedder callback. Eventually we intend to wrap all callbacks in this fashion, so the embedder would never needs to construct a CallbackScope.

A CallbackScope<()>, without context, can be created from:

  • &mut Isolate
  • &mut OwnedIsolate

A CallbackScope, with context, can be created from:

  • Local<Context>
  • Local<Message>
  • Local<Object>
  • Local<Promise>
  • Local<SharedArrayBuffer>
  • &FunctionCallbackInfo
  • &PropertyCallbackInfo
  • &PromiseRejectMessage

Implementations

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.

Trait Implementations

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

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

Performs the conversion.

Performs the conversion.

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.