Struct rquickjs_core::Module
source · [−]pub struct Module<'js, S = Evaluated>(_, _);
Expand description
Javascript module with certain exports and imports
Implementations
sourceimpl<'js> Module<'js>
impl<'js> Module<'js>
sourcepub fn new<N, S>(
ctx: Ctx<'js>,
name: N,
source: S
) -> Result<Module<'js, Loaded<Script>>> where
N: Into<Vec<u8>>,
S: Into<Vec<u8>>,
pub fn new<N, S>(
ctx: Ctx<'js>,
name: N,
source: S
) -> Result<Module<'js, Loaded<Script>>> where
N: Into<Vec<u8>>,
S: Into<Vec<u8>>,
Create module from JS source
sourcepub fn new_def<D, N>(
ctx: Ctx<'js>,
name: N
) -> Result<Module<'js, Loaded<Native>>> where
D: ModuleDef,
N: Into<Vec<u8>>,
pub fn new_def<D, N>(
ctx: Ctx<'js>,
name: N
) -> Result<Module<'js, Loaded<Native>>> where
D: ModuleDef,
N: Into<Vec<u8>>,
Create native JS module using ModuleDef
sourcepub unsafe fn new_raw<N>(
ctx: Ctx<'js>,
name: N,
load: ModuleLoadFn
) -> Result<Module<'js, Loaded<Native>>> where
N: Into<Vec<u8>>,
pub unsafe fn new_raw<N>(
ctx: Ctx<'js>,
name: N,
load: ModuleLoadFn
) -> Result<Module<'js, Loaded<Native>>> where
N: Into<Vec<u8>>,
Create native JS module by calling init function (like js_module_init
)
Safety
The load
function should not crash. But it can throw exception and return null pointer in that case.
sourceimpl<'js> Module<'js, Loaded<Script>>
impl<'js> Module<'js, Loaded<Script>>
sourceimpl<'js, S> Module<'js, Loaded<S>>
impl<'js, S> Module<'js, Loaded<S>>
sourcepub fn eval(self) -> Result<Module<'js, Evaluated>>
pub fn eval(self) -> Result<Module<'js, Evaluated>>
Evaluate a loaded module
To get access to module exports it should be evaluated first, in particular when you create module manually via Module::new
.
sourcepub fn into_loaded(self) -> Module<'js, Loaded>
pub fn into_loaded(self) -> Module<'js, Loaded>
Cast the specific loaded module to generic one
sourceimpl<'js> Module<'js>
impl<'js> Module<'js>
sourcepub fn get<N, T>(&self, name: N) -> Result<T> where
N: AsRef<str>,
T: FromJs<'js>,
pub fn get<N, T>(&self, name: N) -> Result<T> where
N: AsRef<str>,
T: FromJs<'js>,
Return exported value by name
sourcepub fn names<N>(&self) -> ExportNamesIter<'js, N>ⓘNotable traits for ExportNamesIter<'js, N>impl<'js, N> Iterator for ExportNamesIter<'js, N> where
N: FromAtom<'js>, type Item = Result<N>;
where
N: FromAtom<'js>,
Available on crate feature exports
only.
pub fn names<N>(&self) -> ExportNamesIter<'js, N>ⓘNotable traits for ExportNamesIter<'js, N>impl<'js, N> Iterator for ExportNamesIter<'js, N> where
N: FromAtom<'js>, type Item = Result<N>;
where
N: FromAtom<'js>,
N: FromAtom<'js>, type Item = Result<N>;
exports
only.Returns a iterator over the exported names of the module export.
sourcepub fn entries<N, T>(&self) -> ExportEntriesIter<'js, N, T>ⓘNotable traits for ExportEntriesIter<'js, N, T>impl<'js, N, T> Iterator for ExportEntriesIter<'js, N, T> where
N: FromAtom<'js>,
T: FromJs<'js>, type Item = Result<(N, T)>;
where
N: FromAtom<'js>,
T: FromJs<'js>,
Available on crate feature exports
only.
pub fn entries<N, T>(&self) -> ExportEntriesIter<'js, N, T>ⓘNotable traits for ExportEntriesIter<'js, N, T>impl<'js, N, T> Iterator for ExportEntriesIter<'js, N, T> where
N: FromAtom<'js>,
T: FromJs<'js>, type Item = Result<(N, T)>;
where
N: FromAtom<'js>,
T: FromJs<'js>,
N: FromAtom<'js>,
T: FromJs<'js>, type Item = Result<(N, T)>;
exports
only.Returns a iterator over the items the module export.
Methods from Deref<Target = Value<'js>>
sourcepub fn is_function(&self) -> bool
pub fn is_function(&self) -> bool
Check if the value is a function
sourcepub unsafe fn ref_string(&self) -> &String<'js>
pub unsafe fn ref_string(&self) -> &String<'js>
sourcepub unsafe fn ref_symbol(&self) -> &Symbol<'js>
pub unsafe fn ref_symbol(&self) -> &Symbol<'js>
sourcepub unsafe fn ref_object(&self) -> &Object<'js>
pub unsafe fn ref_object(&self) -> &Object<'js>
sourcepub unsafe fn ref_function(&self) -> &Function<'js>
pub unsafe fn ref_function(&self) -> &Function<'js>
sourcepub fn as_function(&self) -> Option<&Function<'js>>
pub fn as_function(&self) -> Option<&Function<'js>>
Try reinterprete as
Trait Implementations
sourceimpl<'js, S: PartialEq> PartialEq<Module<'js, S>> for Module<'js, S>
impl<'js, S: PartialEq> PartialEq<Module<'js, S>> for Module<'js, S>
impl<'js, S> StructuralPartialEq for Module<'js, S>
Auto Trait Implementations
impl<'js, S = Evaluated> !RefUnwindSafe for Module<'js, S>
impl<'js, S = Evaluated> !Send for Module<'js, S>
impl<'js, S = Evaluated> !Sync for Module<'js, S>
impl<'js, S> Unpin for Module<'js, S> where
S: Unpin,
impl<'js, S> UnwindSafe for Module<'js, S> where
S: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more