Struct v8::Context

source ·
#[repr(C)]
pub struct Context(_);
Expand description

A sandboxed execution context with its own set of built-in objects and functions.

Implementations§

Creates a new context.

Creates a new context using the object template as the template for the global object.

Returns the global proxy object.

Global proxy object is a thin wrapper whose prototype points to actual context’s global object with the properties like Object, etc. This is done that way for security reasons (for more details see https://wiki.mozilla.org/Gecko:SplitWindow).

Please note that changes to global proxy object prototype most probably would break VM—v8 expects only global object as a prototype of global proxy object.

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

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

Use with Context::get_slot and Context::get_slot_mut to associate state with a Context.

This method gives ownership of value to the Context. Exactly one object of each type can be associated with a Context. 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 context is garbage collected.

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

Removes all embedder data added with Self::set_slot(), and deletes any internal state needed to keep track of such slots.

This is needed to make a snapshot with SnapshotCreator, since the internal embedder state uses Weak handles, which cannot be alive at the time of snapshotting.

Create a new context from a (non-default) context snapshot. There is no way to provide a global object template since we do not create a new global object from template, but we can reuse a global object.

Methods from Deref<Target = Data>§

Returns true if this data is a BigInt.

Returns true if this data is a Boolean.

Returns true if this data is a Context.

Returns true if this data is a FixedArray.

Returns true if this data is a FunctionTemplate.

Returns true if this data is a Module.

Returns true if this data is a ModuleRequest.

Returns true if this data is a Name.

Returns true if this data is a Number.

Returns true if this data is a ObjectTemplate.

Returns true if this data is a Primitive.

Returns true if this data is a Private.

Returns true if this data is a String.

Returns true if this data is a Symbol.

Returns true if this data is a Value.

Trait Implementations§

Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Dereferences the value.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

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.