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) -> Selfwhere
N: Into<Vec<u8>>,
S: Into<Vec<u8>>,
pub fn source<N, S>(name: N, source: S) -> Selfwhere N: Into<Vec<u8>>, S: Into<Vec<u8>>,
Create module data for a module loaded from source.
sourcepub unsafe fn bytecode<N, S>(name: N, bytecode: S) -> Selfwhere
N: Into<Vec<u8>>,
S: Into<Cow<'static, [u8]>>,
pub unsafe fn bytecode<N, S>(name: N, bytecode: S) -> Selfwhere N: Into<Vec<u8>>, S: Into<Cow<'static, [u8]>>,
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) -> Selfwhere
D: ModuleDef,
N: Into<Vec<u8>>,
pub fn native<D, N>(name: N) -> Selfwhere D: ModuleDef, N: Into<Vec<u8>>,
Create module data for a module loaded from a native rust definition.
sourcepub unsafe fn raw<N>(name: N, load_fn: ModuleLoadFn) -> Selfwhere
N: Into<Vec<u8>>,
pub unsafe fn raw<N>(name: N, load_fn: ModuleLoadFn) -> Selfwhere N: Into<Vec<u8>>,
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 valeus
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