Struct rquickjs_core::Module [−][src]
Javascript module with certain exports and imports
Implementations
impl<'js> Module<'js>
[src]
pub fn name<N>(&self) -> Result<N> where
N: FromAtom<'js>,
[src]
N: FromAtom<'js>,
Returns the name of the module
pub fn meta<T>(&self) -> Result<T> where
T: FromJs<'js>,
[src]
T: FromJs<'js>,
Return the import.meta
object of a module
impl<'js> Module<'js>
[src]
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>>,
[src]
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
pub fn new_def<D, N>(
ctx: Ctx<'js>,
name: N
) -> Result<Module<'js, Loaded<Native>>> where
D: ModuleDef,
N: Into<Vec<u8>>,
[src]
ctx: Ctx<'js>,
name: N
) -> Result<Module<'js, Loaded<Native>>> where
D: ModuleDef,
N: Into<Vec<u8>>,
Create native JS module using ModuleDef
pub unsafe fn new_raw<N>(
ctx: Ctx<'js>,
name: N,
load: ModuleLoadFn
) -> Result<Module<'js, Loaded<Native>>> where
N: Into<Vec<u8>>,
[src]
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.
pub unsafe extern "C" fn init_raw<D>(
ctx: *mut JSContext,
name: *const c_char
) -> *mut JSModuleDef where
D: ModuleDef,
[src]
ctx: *mut JSContext,
name: *const c_char
) -> *mut JSModuleDef where
D: ModuleDef,
The function for loading native JS module
Safety
This function should only be called from js_module_init
function.
impl<'js> Module<'js, Loaded<Script>>
[src]
pub fn read_object<B: AsRef<[u8]>>(ctx: Ctx<'js>, buf: B) -> Result<Self>
[src]
Load module from bytecode
pub fn read_object_const(ctx: Ctx<'js>, buf: &'static [u8]) -> Result<Self>
[src]
Load module from bytecode (static const)
pub fn write_object(&self, byte_swap: bool) -> Result<Vec<u8>>
[src]
Write bytecode of loaded module
impl<'js> Module<'js, Loaded<Native>>
[src]
pub fn set<N, T>(&self, name: N, value: T) -> Result<()> where
N: AsRef<str>,
T: IntoJs<'js>,
[src]
N: AsRef<str>,
T: IntoJs<'js>,
Set exported entry by name
NOTE: Exported entries should be added before module instantiating using Module::add.
impl<'js, S> Module<'js, Loaded<S>>
[src]
pub fn eval(self) -> Result<Module<'js, Evaluated>>
[src]
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
.
pub fn into_loaded(self) -> Module<'js, Loaded>
[src]
Cast the specific loaded module to generic one
impl<'js> Module<'js, Created>
[src]
pub fn add<N>(&self, name: N) -> Result<()> where
N: AsRef<str>,
[src]
N: AsRef<str>,
Add entry to module exports
NOTE: Added entries should be set after module instantiating using Module::set.
impl<'js> Module<'js>
[src]
pub fn get<N, T>(&self, name: N) -> Result<T> where
N: AsRef<str>,
T: FromJs<'js>,
[src]
N: AsRef<str>,
T: FromJs<'js>,
Return exported value by name
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>,
[src]
Notable traits for ExportNamesIter<'js, N>
impl<'js, N> Iterator for ExportNamesIter<'js, N> where
N: FromAtom<'js>, type Item = Result<N>;
N: FromAtom<'js>,
exports
only.Returns a iterator over the exported names of the module export.
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>,
[src]
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)>;
N: FromAtom<'js>,
T: FromJs<'js>,
exports
only.Returns a iterator over the items the module export.
impl<'js> Module<'js, Evaluated>
[src]
pub fn as_value(&self) -> &Value<'js>
[src]
Reference to value
pub fn into_value(self) -> Value<'js>
[src]
Convert into value
pub fn from_value(value: Value<'js>) -> Result<Self>
[src]
Convert from value
Methods from Deref<Target = Value<'js>>
pub fn as_bool(&self) -> Option<bool>
[src]
Try get bool from value
pub fn as_int(&self) -> Option<i32>
[src]
Try get int from value
pub fn as_float(&self) -> Option<f64>
[src]
Try get float from value
pub fn as_number(&self) -> Option<f64>
[src]
Try get any number from value
pub fn is_bool(&self) -> bool
[src]
Check if the value is a bool
pub fn is_int(&self) -> bool
[src]
Check if the value is an int
pub fn is_float(&self) -> bool
[src]
Check if the value is a float
pub fn is_number(&self) -> bool
[src]
Check if the value is an any number
pub fn is_string(&self) -> bool
[src]
Check if the value is a string
pub fn is_symbol(&self) -> bool
[src]
Check if the value is a symbol
pub fn is_object(&self) -> bool
[src]
Check if the value is an object
pub fn is_module(&self) -> bool
[src]
Check if the value is a module
pub fn is_array(&self) -> bool
[src]
Check if the value is an array
pub fn is_function(&self) -> bool
[src]
Check if the value is a function
pub fn is_error(&self) -> bool
[src]
Check if the value is an error
pub fn as_value(&self) -> &Self
[src]
Reference as value
pub fn get<T: FromJs<'js>>(&self) -> Result<T>
[src]
Convert from value to specified type
pub fn type_of(&self) -> Type
[src]
Get the type of value
pub fn type_name(&self) -> &'static str
[src]
Get the name of type
pub unsafe fn ref_string(&self) -> &String<'js>
[src]
pub fn as_string(&self) -> Option<&String<'js>>
[src]
Try reinterprete as
pub unsafe fn ref_symbol(&self) -> &Symbol<'js>
[src]
pub fn as_symbol(&self) -> Option<&Symbol<'js>>
[src]
Try reinterprete as
pub unsafe fn ref_object(&self) -> &Object<'js>
[src]
pub fn as_object(&self) -> Option<&Object<'js>>
[src]
Try reinterprete as
pub unsafe fn ref_array(&self) -> &Array<'js>
[src]
pub fn as_array(&self) -> Option<&Array<'js>>
[src]
Try reinterprete as
pub unsafe fn ref_function(&self) -> &Function<'js>
[src]
pub fn as_function(&self) -> Option<&Function<'js>>
[src]
Try reinterprete as
pub unsafe fn ref_module(&self) -> &Module<'js, Evaluated>
[src]
pub fn as_module(&self) -> Option<&Module<'js, Evaluated>>
[src]
Try reinterprete as
Trait Implementations
impl<'js> AsRef<Value<'js>> for Module<'js, Evaluated>
[src]
impl<'js, S> Clone for Module<'js, S>
[src]
fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'js, S: Debug> Debug for Module<'js, S>
[src]
impl<'js> Deref for Module<'js, Evaluated>
[src]
type Target = Value<'js>
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
impl<'js> From<Module<'js, Evaluated>> for Value<'js>
[src]
impl<'js> FromJs<'js> for Module<'js, Evaluated>
[src]
impl<'js> IntoAtom<'js> for Module<'js, Evaluated>
[src]
impl<'js> IntoJs<'js> for Module<'js, Evaluated>
[src]
impl<'js, S: PartialEq> PartialEq<Module<'js, S>> for Module<'js, S>
[src]
impl<'js, S> StructuralPartialEq for Module<'js, S>
[src]
Auto Trait Implementations
impl<'js, S = Evaluated> !RefUnwindSafe for Module<'js, S>
[src]
impl<'js, S = Evaluated> !Send for Module<'js, S>
[src]
impl<'js, S = Evaluated> !Sync for Module<'js, S>
[src]
impl<'js, S> Unpin for Module<'js, S> where
S: Unpin,
[src]
S: Unpin,
impl<'js, S> UnwindSafe for Module<'js, S> where
S: UnwindSafe,
[src]
S: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,