Skip to main content

JsModuleDef

Struct JsModuleDef 

Source
#[repr(C)]
pub struct JsModuleDef { pub name: String, pub declared: Vec<String>, pub values: Vec<(String, Value)>, pub init: ModuleInitFunc, pub private: Option<Value>, }
Expand description

JSModuleDef: a C module’s definition, as JS_NewCModule answers it.

The C side only passes it back, so the fields are ours — but it has to be a real allocation with a stable address, because JS_AddModuleExport is called with the same pointer the init function was given. It is repr(C) for the same reason: nothing on the C side looks inside, and a plain Rust layout is all it needs.

Fields§

§name: String

The module name, as JS_NewCModule received it.

§declared: Vec<String>

The exports added with JS_AddModuleExport/JS_AddModuleExportList.

§values: Vec<(String, Value)>

The values set with JS_SetModuleExport.

Engine values, not JSValues: JS_SetModuleExport consumes the reference it is given (as the C API says it does), so what is kept is the engine’s own handle. That keeps the module definition out of the reference-counting business entirely, and a definition therefore needs no Drop.

§init: ModuleInitFunc

The function that fills the exports in, run when the module is instantiated.

§private: Option<Value>

JS_SetModulePrivateValue’s value, which a host uses to reach its own data from a module’s callbacks.

Auto Trait Implementations§

§

impl !RefUnwindSafe for JsModuleDef

§

impl !Send for JsModuleDef

§

impl !Sync for JsModuleDef

§

impl !UnwindSafe for JsModuleDef

§

impl Forget for JsModuleDef

§

impl Freeze for JsModuleDef
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<String>: Freeze, PhantomData<(String, Value)>: Freeze, *const GcBox<JsString> is !null: Freeze, *const GcBox<JsObject> is !null: Freeze, *const GcBox<JsSymbol> is !null: Freeze, *const GcBox<BigInt> is !null: Freeze,

§

impl Move for JsModuleDef

§

impl Unpin for JsModuleDef
where *const u8 is !null: Unpin, *const GcBox<JsString> is !null: Unpin, *const GcBox<JsObject> is !null: Unpin, *const GcBox<JsSymbol> is !null: Unpin, *const GcBox<BigInt> is !null: Unpin,

§

impl UnsafeUnpin for JsModuleDef

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.