pub struct SimpleModuleLoader { /* private fields */ }Expand description
A simple module loader that loads modules relative to a root path.
§Note
This loader only works by using the type methods SimpleModuleLoader::insert and
SimpleModuleLoader::get. The utility methods on ModuleLoader don’t work at the moment,
but we’ll unify both APIs in the future.
Implementations§
Source§impl SimpleModuleLoader
impl SimpleModuleLoader
Sourcepub fn new<P: AsRef<Path>>(root: P) -> JsResult<Self>
pub fn new<P: AsRef<Path>>(root: P) -> JsResult<Self>
Creates a new SimpleModuleLoader from a root module path.
Sourcepub fn insert_with_attributes(
&self,
path: PathBuf,
attributes: &[ImportAttribute],
module: Module,
)
pub fn insert_with_attributes( &self, path: PathBuf, attributes: &[ImportAttribute], module: Module, )
Inserts a new module onto the module map with the given attributes.
Sourcepub fn get_with_attributes(
&self,
path: &Path,
attributes: &[ImportAttribute],
) -> Option<Module>
pub fn get_with_attributes( &self, path: &Path, attributes: &[ImportAttribute], ) -> Option<Module>
Gets a module from its original path and attributes.
Trait Implementations§
Source§impl Debug for SimpleModuleLoader
impl Debug for SimpleModuleLoader
Source§impl ModuleLoader for SimpleModuleLoader
impl ModuleLoader for SimpleModuleLoader
Auto Trait Implementations§
impl !Freeze for SimpleModuleLoader
impl !RefUnwindSafe for SimpleModuleLoader
impl !Send for SimpleModuleLoader
impl !Sync for SimpleModuleLoader
impl !UnwindSafe for SimpleModuleLoader
impl Unpin for SimpleModuleLoader
impl UnsafeUnpin for SimpleModuleLoader
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
Source§impl<ModuleLoaderImplementor> DynModuleLoader for ModuleLoaderImplementorwhere
ModuleLoaderImplementor: ModuleLoader,
impl<ModuleLoaderImplementor> DynModuleLoader for ModuleLoaderImplementorwhere
ModuleLoaderImplementor: ModuleLoader,
Source§fn load_imported_module<'context0, 'context1, 'dynify>(
self: Rc<ModuleLoaderImplementor>,
referrer: Referrer,
request: ModuleRequest,
context: &'context0 RefCell<&'context1 mut Context>,
) -> Fn<(RcSelf, Referrer, ModuleRequest, &'context0 RefCell<&'context1 mut Context>), dyn Future<Output = Result<Module, JsError>> + 'dynify>where
'context0: 'dynify,
'context1: 'dynify,
ModuleLoaderImplementor: 'dynify,
fn load_imported_module<'context0, 'context1, 'dynify>(
self: Rc<ModuleLoaderImplementor>,
referrer: Referrer,
request: ModuleRequest,
context: &'context0 RefCell<&'context1 mut Context>,
) -> Fn<(RcSelf, Referrer, ModuleRequest, &'context0 RefCell<&'context1 mut Context>), dyn Future<Output = Result<Module, JsError>> + 'dynify>where
'context0: 'dynify,
'context1: 'dynify,
ModuleLoaderImplementor: 'dynify,
Host hook HostLoadImportedModule ( referrer, specifier, hostDefined, payload ).
This hook allows to customize the module loading functionality of the engine. Technically,
this should call the FinishLoadingImportedModule operation, but this simpler API just provides
an async method that replaces FinishLoadingImportedModule.
§Requirements
- The host environment must perform
FinishLoadingImportedModule(referrer, specifier, payload, result), where result is either a normal completion containing the loaded Module Record or a throw completion, either synchronously or asynchronously. This is replaced by simply returning from the method. - If this operation is called multiple times with the same
(referrer, specifier)pair and it performs FinishLoadingImportedModule(referrer, specifier, payload, result) where result is a normal completion, then it must performFinishLoadingImportedModule(referrer, specifier, payload, result)with the same result each time. - The operation must treat payload as an opaque value to be passed through to
FinishLoadingImportedModule. (can be ignored)
Source§fn init_import_meta(
self: Rc<ModuleLoaderImplementor>,
import_meta: &JsObject,
module: &Module,
context: &mut Context,
)
fn init_import_meta( self: Rc<ModuleLoaderImplementor>, import_meta: &JsObject, module: &Module, context: &mut Context, )
Host hooks HostGetImportMetaProperties ( moduleRecord ) and
HostFinalizeImportMeta ( importMeta, moduleRecord ).
This unifies both APIs into a single hook that can be overridden on both cases.
The most common usage is to add properties to import_meta and return, but this also
allows modifying the import meta object in more exotic ways before exposing it to ECMAScript
code.
The default implementation of HostGetImportMetaProperties is to return a new empty List.
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.