Struct v8::Module

source ·
#[repr(C)]
pub struct Module(/* private fields */);
Expand description

A compiled JavaScript module.

Implementations§

source§

impl Module

source

pub fn get_status(&self) -> ModuleStatus

Returns the module’s current status.

source

pub fn get_exception(&self) -> Local<'_, Value>

For a module in kErrored status, this returns the corresponding exception.

source

pub fn get_module_requests(&self) -> Local<'_, FixedArray>

Returns the ModuleRequests for this module.

source

pub fn source_offset_to_location(&self, offset: int) -> Location

For the given source text offset in this module, returns the corresponding Location with line and column numbers.

source

pub fn get_identity_hash(&self) -> NonZeroI32

Returns the V8 hash value for this value. The current implementation uses a hidden property to store the identity hash.

The return value will never be 0. Also, it is not guaranteed to be unique.

source

pub fn script_id(&self) -> Option<int>

Returns the underlying script’s id.

The module must be a SourceTextModule and must not have an Errored status.

source

pub fn get_module_namespace(&self) -> Local<'_, Value>

Returns the namespace object of this module.

The module’s status must be at least kInstantiated.

source

pub fn instantiate_module<'a>( &self, scope: &mut HandleScope<'_>, callback: impl MapFnTo<ResolveModuleCallback<'a>> ) -> Option<bool>

Instantiates the module and its dependencies.

Returns an empty Maybe if an exception occurred during instantiation. (In the case where the callback throws an exception, that exception is propagated.)

NOTE: requires to set --harmony-import-assertions V8 flag.

source

pub fn evaluate<'s>( &self, scope: &mut HandleScope<'s> ) -> Option<Local<'s, Value>>

Evaluates the module and its dependencies.

If status is kInstantiated, run the module’s code. On success, set status to kEvaluated and return the completion value; on failure, set status to kErrored and propagate the thrown exception (which is then also available via |GetException|).

source

pub fn is_source_text_module(&self) -> bool

Returns whether the module is a SourceTextModule.

source

pub fn is_synthetic_module(&self) -> bool

Returns whether the module is a SyntheticModule.

source

pub fn create_synthetic_module<'s, 'a>( scope: &mut HandleScope<'s>, module_name: Local<'_, String>, export_names: &[Local<'_, String>], evaluation_steps: impl MapFnTo<SyntheticModuleEvaluationSteps<'a>> ) -> Local<'s, Module>

Creates a new SyntheticModule with the specified export names, where evaluation_steps will be executed upon module evaluation. export_names must not contain duplicates. module_name is used solely for logging/debugging and doesn’t affect module behavior.

source

pub fn set_synthetic_module_export( &self, scope: &mut HandleScope<'_>, export_name: Local<'_, String>, export_value: Local<'_, Value> ) -> Option<bool>

Set this module’s exported value for the name export_name to the specified export_value. This method must be called only on Modules created via create_synthetic_module. An error will be thrown if export_name is not one of the export_names that were passed in that create_synthetic_module call. Returns Some(true) on success, None if an error was thrown.

source

pub fn get_unbound_module_script<'s>( &self, scope: &mut HandleScope<'s> ) -> Local<'s, UnboundModuleScript>

source

pub fn get_stalled_top_level_await_message( &self, scope: &mut HandleScope<'_> ) -> Vec<(Local<'_, Module>, Local<'_, Message>)>

Search the modules requested directly or indirectly by the module for any top-level await that has not yet resolved. If there is any, the returned vector contains a tuple of the unresolved module and a message with the pending top-level await. An embedder may call this before exiting to improve error messages.

Methods from Deref<Target = Data>§

source

pub fn is_big_int(&self) -> bool

Returns true if this data is a BigInt.

source

pub fn is_boolean(&self) -> bool

Returns true if this data is a Boolean.

source

pub fn is_context(&self) -> bool

Returns true if this data is a Context.

source

pub fn is_fixed_array(&self) -> bool

Returns true if this data is a FixedArray.

source

pub fn is_function_template(&self) -> bool

Returns true if this data is a FunctionTemplate.

source

pub fn is_module(&self) -> bool

Returns true if this data is a Module.

source

pub fn is_module_request(&self) -> bool

Returns true if this data is a ModuleRequest.

source

pub fn is_name(&self) -> bool

Returns true if this data is a Name.

source

pub fn is_number(&self) -> bool

Returns true if this data is a Number.

source

pub fn is_object_template(&self) -> bool

Returns true if this data is a ObjectTemplate.

source

pub fn is_primitive(&self) -> bool

Returns true if this data is a Primitive.

source

pub fn is_private(&self) -> bool

Returns true if this data is a Private.

source

pub fn is_string(&self) -> bool

Returns true if this data is a String.

source

pub fn is_symbol(&self) -> bool

Returns true if this data is a Symbol.

source

pub fn is_value(&self) -> bool

Returns true if this data is a Value.

Trait Implementations§

source§

impl Debug for Module

source§

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

Formats the value using the given formatter. Read more
source§

impl Deref for Module

§

type Target = Data

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl Hash for Module

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'s> PartialEq<Data> for Module

source§

fn eq(&self, other: &Data) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'s> PartialEq<Module> for Data

source§

fn eq(&self, other: &Module) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'s> PartialEq for Module

source§

fn eq(&self, other: &Module) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Module

Auto Trait Implementations§

§

impl Freeze for Module

§

impl RefUnwindSafe for Module

§

impl Send for Module

§

impl Sync for Module

§

impl Unpin for Module

§

impl UnwindSafe for Module

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>,

§

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>,

§

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.