pub struct ModuleData { /* private fields */ }
Expand description

The data required to load a module, either from source or native.

Implementations§

source§

impl ModuleData

source

pub fn source<N, S>(name: N, source: S) -> Self
where N: Into<Vec<u8>>, S: Into<Vec<u8>>,

Create module data for a module loaded from source.

source

pub unsafe fn bytecode<N, S>(name: N, bytecode: S) -> Self
where 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.

source

pub fn native<D, N>(name: N) -> Self
where D: ModuleDef, N: Into<Vec<u8>>,

Create module data for a module loaded from a native Rust definition.

source

pub unsafe fn raw<N>(name: N, load_fn: ModuleLoadFn) -> Self
where 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 values and return a pointer to qjs::JSModuleDef, or a null pointer if there was some error.

source

pub fn kind(&self) -> &ModuleDataKind

Returns the kind of ModuleData.

source

pub fn declare<'js>(self, ctx: Ctx<'js>) -> Result<()>

Declare the module defined in the ModuleData.

source

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

source§

fn clone(&self) -> ModuleData

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ModuleData

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> ParallelSend for T