pub trait GuestModuleReader: Send {
// Required method
fn read_module_source(
&mut self,
resolved_guest_path: &str,
) -> Option<String>;
// Provided method
fn resolve_module(
&mut self,
specifier: &str,
referrer: &str,
) -> Option<String> { ... }
}Expand description
Thread-local state for module resolution during execute_module. Avoids passing user data through V8’s ResolveModuleCallback (which is a plain fn pointer). Direct, in-process module source reader living on the V8 session thread.
The V8 module callback (resolve_or_compile_module) runs in this crate
(v8-runtime), but the module reader/resolver lives in the higher execution
crate, so a direct call would be a circular dependency — today every module
resolve/load/format is a sync bridge round-trip (~139us × ~5,100 calls ≈ all
of loadPiSdkRuntime). This trait is owned here and implemented in the higher
crate over the mounted HostDirModuleReader, then handed down to the session
thread so module source can be read directly, skipping the round-trip. It is
confined to the same mounts the guest sees (the impl keeps the reader’s
openat2(RESOLVE_BENEATH) confinement).
Required Methods§
Sourcefn read_module_source(&mut self, resolved_guest_path: &str) -> Option<String>
fn read_module_source(&mut self, resolved_guest_path: &str) -> Option<String>
Read the source for an already-resolved guest module path, or None if
the path isn’t served by this reader (caller falls back to the bridge IPC).
Provided Methods§
Sourcefn resolve_module(&mut self, specifier: &str, referrer: &str) -> Option<String>
fn resolve_module(&mut self, specifier: &str, referrer: &str) -> Option<String>
Resolve a module specifier (import mode) to a resolved guest path directly,
skipping the bridge _resolveModule round-trip. None => fall back to IPC.
Implementations must match the bridge resolver exactly (same cache, same
ESM/CJS/exports/symlink semantics).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".