Struct marine::generic::MarineCore
source · pub struct MarineCore<WB>where
WB: WasmBackend,{ /* private fields */ }
Expand description
§Description
The base struct of Marine, the Fluence compute runtime. Allows dynamic loading and unloading modules, but never frees resources used for instantiation. A new module can import functions from previously loaded modules.
§Recommendations
Its not recommended to use this struct to load/unload unlimited number of modules. Better alternative is to use multiple instances of this struct for independent groups of modules and drop them when the group is no longer needed.
Implementations§
source§impl<WB> MarineCore<WB>where
WB: WasmBackend,
impl<WB> MarineCore<WB>where
WB: WasmBackend,
pub fn new(config: MarineCoreConfig) -> Result<MarineCore<WB>, MError>
sourcepub fn call(
&mut self,
module_name: impl AsRef<str>,
func_name: impl AsRef<str>,
arguments: &[IValue]
) -> Result<Vec<IValue>, MError>
pub fn call( &mut self, module_name: impl AsRef<str>, func_name: impl AsRef<str>, arguments: &[IValue] ) -> Result<Vec<IValue>, MError>
Invoke a function of a module inside Marine by given function name with given arguments.
sourcepub fn load_module(
&mut self,
name: impl Into<String>,
wasm_bytes: &[u8],
config: MModuleConfig<WB>
) -> Result<(), MError>
pub fn load_module( &mut self, name: impl Into<String>, wasm_bytes: &[u8], config: MModuleConfig<WB> ) -> Result<(), MError>
Load a new module inside Marine.
sourcepub fn unload_module(&mut self, name: impl AsRef<str>) -> Result<(), MError>
pub fn unload_module(&mut self, name: impl AsRef<str>) -> Result<(), MError>
Unload previously loaded module.
pub fn module_wasi_state<'s>( &'s mut self, module_name: impl AsRef<str> ) -> Option<Box<dyn WasiState + 's>>
sourcepub fn interface(&self) -> impl Iterator<Item = (&str, MModuleInterface<'_>)>
pub fn interface(&self) -> impl Iterator<Item = (&str, MModuleInterface<'_>)>
Return function signatures of all loaded info Marine modules with their names.
sourcepub fn module_interface(
&self,
module_name: impl AsRef<str>
) -> Option<MModuleInterface<'_>>
pub fn module_interface( &self, module_name: impl AsRef<str> ) -> Option<MModuleInterface<'_>>
Return function signatures exported by module with given name.
sourcepub fn module_record_types(
&self,
module_name: impl AsRef<str>
) -> Option<&HashMap<u64, Arc<RecordType>>>
pub fn module_record_types( &self, module_name: impl AsRef<str> ) -> Option<&HashMap<u64, Arc<RecordType>>>
Return record types exported by module with given name.
sourcepub fn module_record_type_by_id(
&self,
module_name: impl AsRef<str>,
record_id: u64
) -> Option<&Arc<RecordType>>
pub fn module_record_type_by_id( &self, module_name: impl AsRef<str>, record_id: u64 ) -> Option<&Arc<RecordType>>
Return record type for supplied record id exported by module with given name.
sourcepub fn module_memory_stats(&self) -> MemoryStats<'_>
pub fn module_memory_stats(&self) -> MemoryStats<'_>
Returns a heap size that all modules consume in bytes.
pub fn clear_allocation_stats(&mut self)
Auto Trait Implementations§
impl<WB> !Freeze for MarineCore<WB>
impl<WB> !RefUnwindSafe for MarineCore<WB>
impl<WB> Send for MarineCore<WB>
impl<WB> !Sync for MarineCore<WB>
impl<WB> Unpin for MarineCore<WB>
impl<WB> !UnwindSafe for MarineCore<WB>
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<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self
file descriptor.source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self
file descriptor. Read more