Struct rquickjs_core::module::ModuleData
source · pub struct ModuleData { /* private fields */ }
Expand description
The data required to load a module, either from source or native.
Implementations§
source§impl ModuleData
impl ModuleData
sourcepub fn source<N, S>(name: N, source: S) -> Self
pub fn source<N, S>(name: N, source: S) -> Self
Create module data for a module loaded from source.
sourcepub unsafe fn bytecode<N, S>(name: N, bytecode: S) -> Self
pub unsafe fn bytecode<N, S>(name: N, bytecode: S) -> Self
Create module data for a module loaded from source.
§Safety
User must ensure that the bytecode is valid QuickJS bytecode.
sourcepub fn native<D, N>(name: N) -> Self
pub fn native<D, N>(name: N) -> Self
Create module data for a module loaded from a native Rust definition.
sourcepub unsafe fn raw<N>(name: N, load_fn: ModuleLoadFn) -> Self
pub unsafe fn raw<N>(name: N, load_fn: ModuleLoadFn) -> Self
Create module data for a module loaded from a native Rust definition.
§Safety
User must ensure that load_fn
behaves like a loader function.
The function must take a context and a c string without taking ownership of either values
and return a pointer to qjs::JSModuleDef
, or a null pointer if there was some error.
sourcepub fn kind(&self) -> &ModuleDataKind
pub fn kind(&self) -> &ModuleDataKind
Returns the kind of ModuleData
.
sourcepub fn declare<'js>(self, ctx: Ctx<'js>) -> Result<()>
pub fn declare<'js>(self, ctx: Ctx<'js>) -> Result<()>
Declare the module defined in the ModuleData
.
sourcepub unsafe fn unsafe_declare<'js>(self, ctx: Ctx<'js>) -> Result<Module<'js>>
pub unsafe fn unsafe_declare<'js>(self, ctx: Ctx<'js>) -> Result<Module<'js>>
Declare the module defined in the ModuleData
.
§Safety
This method returns an unevaluated module. It is UB to hold unto unevaluated modules across any call to a module function which can invalidate unevaluated modules and returned an error.
Trait Implementations§
source§impl Clone for ModuleData
impl Clone for ModuleData
source§fn clone(&self) -> ModuleData
fn clone(&self) -> ModuleData
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more