pub struct MultiUseGuestCallContext { /* private fields */ }
Expand description
A context for calling guest functions.
Takes ownership of an existing MultiUseSandbox
.
Once created, guest function calls may be made through this and only this context
until it is converted back to the MultiUseSandbox
from which it originated.
Upon this conversion,the memory associated with the MultiUseSandbox
it owns will be reset to the state it was in before
this context was created.
Calls made through this context will cause state to be retained across calls, until such time as the context
is converted back to a MultiUseSandbox
If dropped, the MultiUseSandbox
from which it came will be also be dropped as it is owned by the
MultiUseGuestCallContext
until it is converted back to a MultiUseSandbox
Implementations§
Source§impl MultiUseGuestCallContext
impl MultiUseGuestCallContext
Sourcepub fn start(sbox: MultiUseSandbox) -> Self
pub fn start(sbox: MultiUseSandbox) -> Self
Take ownership of a MultiUseSandbox
and
return a new MultiUseGuestCallContext
instance.
Sourcepub fn finish(self) -> Result<MultiUseSandbox>
pub fn finish(self) -> Result<MultiUseSandbox>
Close out the context and get back the internally-stored
MultiUseSandbox
. Future contexts opened by the returned sandbox
will have guest state restored.
Trait Implementations§
Source§impl Callable for MultiUseGuestCallContext
impl Callable for MultiUseGuestCallContext
Source§fn call<Output: SupportedReturnType>(
&mut self,
func_name: &str,
args: impl ParameterTuple,
) -> Result<Output>
fn call<Output: SupportedReturnType>( &mut self, func_name: &str, args: impl ParameterTuple, ) -> Result<Output>
Call the guest function called func_name
with the given arguments
args
, and expect the return value have the same type as
func_ret_type
.
Every call to a guest function through this method will be made with the same “context” meaning that the guest state resulting from any previous call will be present/osbservable by the guest function called.
If you want to reset state, call finish()
on this MultiUseGuestCallContext
and get a new one from the resulting MultiUseSandbox