[−][src]Struct wapc::WapcHost
A WebAssembly host runtime for waPC-compliant modules
Use an instance of this struct to provide a means of invoking procedure calls by
specifying an operation name and a set of bytes representing the opaque operation payload.
WapcHost
makes no assumptions about the contents or format of either the payload or the
operation name, other than that the operation name is a UTF-8 encoded string.
Implementations
impl WapcHost
[src]
pub fn new(
engine: Box<dyn WebAssemblyEngineProvider>,
host_callback: impl Fn(u64, &str, &str, &str, &[u8]) -> Result<Vec<u8>, Box<dyn Error + Send + Sync>> + 'static + Sync + Send
) -> Result<Self>
[src]
engine: Box<dyn WebAssemblyEngineProvider>,
host_callback: impl Fn(u64, &str, &str, &str, &[u8]) -> Result<Vec<u8>, Box<dyn Error + Send + Sync>> + 'static + Sync + Send
) -> Result<Self>
Creates a new instance of a waPC-compliant host runtime paired with a given low-level engine provider
pub fn id(&self) -> u64
[src]
Returns a reference to the unique identifier of this module. If a parent process
has instantiated multiple WapcHost
s, then the single static host callback function
will contain this value to allow disambiguation of modules
pub fn call(&self, op: &str, payload: &[u8]) -> Result<Vec<u8>>
[src]
Invokes the __guest_call
function within the guest module as per the waPC specification.
Provide an operation name and an opaque payload of bytes and the function returns a Result
containing either an error or an opaque reply of bytes.
It is worth noting that the first time call
is invoked, the WebAssembly module
might incur a "cold start" penalty, depending on which underlying engine you're using. This
might be due to lazy initialization or JIT-compilation.
pub fn replace_module(&self, module: &[u8]) -> Result<()>
[src]
Performs a live "hot swap" of the WebAssembly module. Since all internal waPC execution is assumed to be
single-threaded and non-reentrant, this call is synchronous and so
you should never attempt to invoke call
from another thread while performing this hot swap.
Note: if the underlying engine you've chosen is a JITting engine, then performing a swap will re-introduce a "cold start" delay upon the next function call.
If you perform a hot swap of a WASI module, you cannot alter the parameters used to create the WASI module like the environment variables, mapped directories, pre-opened files, etc. Not abiding by this could lead to privilege escalation attacks or non-deterministic behavior after the swap.
Auto Trait Implementations
impl !RefUnwindSafe for WapcHost
impl !Send for WapcHost
impl !Sync for WapcHost
impl Unpin for WapcHost
impl !UnwindSafe for WapcHost
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,