pub struct ExtensionBuilder { /* private fields */ }
Expand description
Builder to create a ModuleLoader
, ModuleResolver
and GlobalInitializer
§Example
use rquickjs_extension::{Extension, ModuleImpl};
struct MyExtension;
impl Extension for MyExtension {
type Implementation = ModuleImpl<()>;
fn implementation() -> &'static Self::Implementation {
&ModuleImpl {
declare: |decl| {
decl.declare("hello")?;
Ok(())
},
evaluate: |ctx, exports, options| {
exports.export("hello", "world".to_string())?;
Ok(())
},
name: "my-module",
}
}
fn options(self) -> () {}
}
Implementations§
Source§impl ExtensionBuilder
impl ExtensionBuilder
pub fn new() -> Self
pub fn with_extension<O, M, R>(self, extension: M) -> Selfwhere
for<'js> O: JsLifetime<'js> + Send + Sync + 'static,
R: ModuleDef + ModuleMeta,
M: IntoModule<O, R>,
pub fn with_extension_named<O, M, R>(
self,
extension: M,
name: &'static str,
) -> Selfwhere
for<'js> O: JsLifetime<'js> + Send + Sync + 'static,
R: ModuleDef + ModuleMeta,
M: IntoModule<O, R>,
pub fn add_extension<O, M, R>(&mut self, extension: M) -> &mut Selfwhere
for<'js> O: JsLifetime<'js> + Send + Sync + 'static,
R: ModuleDef + ModuleMeta,
M: IntoModule<O, R>,
pub fn add_extension_named<O, M, R>(
&mut self,
extension: M,
name: &'static str,
) -> &mut Selfwhere
for<'js> O: JsLifetime<'js> + Send + Sync + 'static,
R: ModuleDef + ModuleMeta,
M: IntoModule<O, R>,
pub fn build(self) -> (ModuleLoader, ModuleResolver, GlobalInitializer)
Trait Implementations§
Source§impl Default for ExtensionBuilder
impl Default for ExtensionBuilder
Source§fn default() -> ExtensionBuilder
fn default() -> ExtensionBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ExtensionBuilder
impl !RefUnwindSafe for ExtensionBuilder
impl Send for ExtensionBuilder
impl Sync for ExtensionBuilder
impl Unpin for ExtensionBuilder
impl !UnwindSafe for ExtensionBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more