pub struct ModuleLoaderImpl {
runtime: Arc<WASMRuntime>,
config: WASMConfig,
linkers: Arc<RwLock<Vec<Linker<()>>>>,
loaded_modules: Arc<RwLock<Vec<WASMModule>>>,
}Expand description
WASM Module Loader
Fields§
§runtime: Arc<WASMRuntime>§config: WASMConfig§linkers: Arc<RwLock<Vec<Linker<()>>>>§loaded_modules: Arc<RwLock<Vec<WASMModule>>>Implementations§
Source§impl ModuleLoaderImpl
impl ModuleLoaderImpl
Sourcepub fn new(runtime: Arc<WASMRuntime>, config: WASMConfig) -> Self
pub fn new(runtime: Arc<WASMRuntime>, config: WASMConfig) -> Self
Create a new module loader
Sourcepub async fn load_from_file(&self, path: &Path) -> Result<WASMModule>
pub async fn load_from_file(&self, path: &Path) -> Result<WASMModule>
Load a WASM module from a file
Sourcepub async fn load_from_memory(
&self,
wasm_bytes: &[u8],
source_type: ModuleSourceType,
) -> Result<WASMModule>
pub async fn load_from_memory( &self, wasm_bytes: &[u8], source_type: ModuleSourceType, ) -> Result<WASMModule>
Load a WASM module from memory
Sourcepub async fn load_from_url(&self, url: &str) -> Result<WASMModule>
pub async fn load_from_url(&self, url: &str) -> Result<WASMModule>
Load a WASM module from a URL
Sourcepub async fn instantiate(
&self,
module: &Module,
store: Store<StoreLimits>,
) -> Result<WASMInstance>
pub async fn instantiate( &self, module: &Module, store: Store<StoreLimits>, ) -> Result<WASMInstance>
Instantiate a loaded module
Sourcepub async fn get_loaded_modules(&self) -> Vec<WASMModule>
pub async fn get_loaded_modules(&self) -> Vec<WASMModule>
Get all loaded modules
Sourcepub async fn get_module_by_id(&self, id: &str) -> Option<WASMModule>
pub async fn get_module_by_id(&self, id: &str) -> Option<WASMModule>
Get a loaded module by ID
Sourcepub async fn unload_module(&self, id: &str) -> Result<bool>
pub async fn unload_module(&self, id: &str) -> Result<bool>
Unload a module
Sourcefn extract_module_info(&self, module: &Module) -> ModuleInfo
fn extract_module_info(&self, module: &Module) -> ModuleInfo
Extract module information from a compiled module
Sourcefn compute_hash(&self, wasm_bytes: &[u8]) -> Option<String>
fn compute_hash(&self, wasm_bytes: &[u8]) -> Option<String>
Compute a hash of the WASM bytes for caching
Auto Trait Implementations§
impl Freeze for ModuleLoaderImpl
impl !RefUnwindSafe for ModuleLoaderImpl
impl Send for ModuleLoaderImpl
impl Sync for ModuleLoaderImpl
impl Unpin for ModuleLoaderImpl
impl !UnwindSafe for ModuleLoaderImpl
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request