#[repr(C)]pub struct Module(_);
Expand description
A compiled JavaScript module.
Implementations§
source§impl Module
impl Module
sourcepub fn get_status(&self) -> ModuleStatus
pub fn get_status(&self) -> ModuleStatus
Returns the module’s current status.
sourcepub fn get_exception(&self) -> Local<'_, Value>
pub fn get_exception(&self) -> Local<'_, Value>
For a module in kErrored status, this returns the corresponding exception.
sourcepub fn get_module_requests(&self) -> Local<'_, FixedArray>
pub fn get_module_requests(&self) -> Local<'_, FixedArray>
Returns the ModuleRequests for this module.
sourcepub fn source_offset_to_location(&self, offset: int) -> Location
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.
sourcepub fn get_identity_hash(&self) -> NonZeroI32
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.
sourcepub fn script_id(&self) -> Option<int>
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.
sourcepub fn get_module_namespace(&self) -> Local<'_, Value>
pub fn get_module_namespace(&self) -> Local<'_, Value>
Returns the namespace object of this module.
The module’s status must be at least kInstantiated.
sourcepub fn instantiate_module<'a>(
&self,
scope: &mut HandleScope<'_>,
callback: impl MapFnTo<ResolveModuleCallback<'a>>
) -> Option<bool>
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
NOTE: requires to set --harmony-import-assertions
V8 flag.
sourcepub fn evaluate<'s>(
&self,
scope: &mut HandleScope<'s>
) -> Option<Local<'s, Value>>
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|).
sourcepub fn is_source_text_module(&self) -> bool
pub fn is_source_text_module(&self) -> bool
Returns whether the module is a SourceTextModule.
sourcepub fn is_synthetic_module(&self) -> bool
pub fn is_synthetic_module(&self) -> bool
Returns whether the module is a SyntheticModule.
sourcepub 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>
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.
sourcepub fn set_synthetic_module_export(
&self,
scope: &mut HandleScope<'_>,
export_name: Local<'_, String>,
export_value: Local<'_, Value>
) -> Option<bool>
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.
pub fn get_unbound_module_script<'s>(
&self,
scope: &mut HandleScope<'s>
) -> Local<'s, UnboundModuleScript>
Methods from Deref<Target = Data>§
sourcepub fn is_big_int(&self) -> bool
pub fn is_big_int(&self) -> bool
Returns true if this data is a BigInt
.
sourcepub fn is_boolean(&self) -> bool
pub fn is_boolean(&self) -> bool
Returns true if this data is a Boolean
.
sourcepub fn is_context(&self) -> bool
pub fn is_context(&self) -> bool
Returns true if this data is a Context
.
sourcepub fn is_fixed_array(&self) -> bool
pub fn is_fixed_array(&self) -> bool
Returns true if this data is a FixedArray
.
sourcepub fn is_function_template(&self) -> bool
pub fn is_function_template(&self) -> bool
Returns true if this data is a FunctionTemplate
.
sourcepub fn is_module_request(&self) -> bool
pub fn is_module_request(&self) -> bool
Returns true if this data is a ModuleRequest
.
sourcepub fn is_object_template(&self) -> bool
pub fn is_object_template(&self) -> bool
Returns true if this data is a ObjectTemplate
.
sourcepub fn is_primitive(&self) -> bool
pub fn is_primitive(&self) -> bool
Returns true if this data is a Primitive
.
sourcepub fn is_private(&self) -> bool
pub fn is_private(&self) -> bool
Returns true if this data is a Private
.