[][src]Struct rusty_v8::CallbackScope

pub struct CallbackScope<'s> { /* fields omitted */ }

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 can be created from the following inputs:

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

Implementations

impl<'s> CallbackScope<'s>[src]

pub unsafe fn new<P: NewCallbackScope<'s>>(param: P) -> Self[src]

Methods from Deref<Target = HandleScope<'s>>

pub fn get_current_context(&self) -> Local<'s, Context>[src]

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

pub fn get_entered_or_microtask_context(&self) -> Local<'s, Context>[src]

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.

pub fn throw_exception(&mut self, exception: Local<Value>) -> Local<'s, Value>[src]

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.

Trait Implementations

impl<'s> AsMut<HandleScope<'s, ()>> for CallbackScope<'s>[src]

impl<'s> AsMut<HandleScope<'s, Context>> for CallbackScope<'s>[src]

impl<'s> AsMut<Isolate> for CallbackScope<'s>[src]

impl<'s> AsRef<HandleScope<'s, ()>> for CallbackScope<'s>[src]

impl<'s> AsRef<HandleScope<'s, Context>> for CallbackScope<'s>[src]

impl<'s> AsRef<Isolate> for CallbackScope<'s>[src]

impl<'s> Deref for CallbackScope<'s>[src]

type Target = HandleScope<'s>

The resulting type after dereferencing.

impl<'s> DerefMut for CallbackScope<'s>[src]

impl<'s> Drop for CallbackScope<'s>[src]

Auto Trait Implementations

impl<'s> !RefUnwindSafe for CallbackScope<'s>

impl<'s> !Send for CallbackScope<'s>

impl<'s> !Sync for CallbackScope<'s>

impl<'s> Unpin for CallbackScope<'s>

impl<'s> !UnwindSafe for CallbackScope<'s>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.