CallbackScope

Struct CallbackScope 

Source
pub struct CallbackScope<'s, C = Context> { /* private fields */ }
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
  • &FastApiCallbackOptions

Implementations§

Source§

impl<'s> CallbackScope<'s>

Source

pub unsafe fn new<P: NewCallbackScope<'s>>( param: P, ) -> ScopeStorage<P::NewScope>

Trait Implementations§

Source§

impl<C> AsRef<Isolate> for CallbackScope<'_, C>

Source§

fn as_ref(&self) -> &Isolate

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'s> AsRef<Pin<&'s mut HandleScope<'s, ()>>> for CallbackScope<'s, ()>

Source§

fn as_ref(&self) -> &Pin<&'s mut HandleScope<'s, ()>>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'s, C: Debug> Debug for CallbackScope<'s, C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'s, C = Context> !Freeze for CallbackScope<'s, C>

§

impl<'s, C = Context> !RefUnwindSafe for CallbackScope<'s, C>

§

impl<'s, C = Context> !Send for CallbackScope<'s, C>

§

impl<'s, C = Context> !Sync for CallbackScope<'s, C>

§

impl<'s, C = Context> !Unpin for CallbackScope<'s, C>

§

impl<'s, C> UnwindSafe for CallbackScope<'s, C>
where C: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,