pub enum RunResult {
Returned(UntypedRetVal),
Yielded(YieldedVal),
}
Expand description
The result of running or resuming an Instance
.
Variants§
Returned(UntypedRetVal)
An instance returned with a value.
The actual type of the contained value depends on the return type of the guest function that was called. For guest functions with no return value, it is undefined behavior to do anything with this value.
Yielded(YieldedVal)
An instance yielded, potentially with a value.
This arises when a hostcall invokes one of the
Vmctx::yield_*()
family of methods. Depending on which
variant is used, the YieldedVal
may contain a value passed from the guest context to the
host.
An instance that has yielded may only be resumed (with or without a value to returned to the guest), reset, or dropped. Attempting to run an instance from a new entrypoint after it has yielded but without first resetting will result in an error.
Implementations§
Source§impl RunResult
impl RunResult
Sourcepub fn returned(self) -> Result<UntypedRetVal, Error>
pub fn returned(self) -> Result<UntypedRetVal, Error>
Try to get a return value from a run result, returning Error::InstanceNotReturned
if the
instance instead yielded.
Sourcepub fn returned_ref(&self) -> Result<&UntypedRetVal, Error>
pub fn returned_ref(&self) -> Result<&UntypedRetVal, Error>
Try to get a reference to a return value from a run result, returning
Error::InstanceNotReturned
if the instance instead yielded.
Sourcepub fn is_returned(&self) -> bool
pub fn is_returned(&self) -> bool
Returns true
if the instance returned a value.
Sourcepub fn expect_returned(self, msg: &str) -> UntypedRetVal
pub fn expect_returned(self, msg: &str) -> UntypedRetVal
Unwraps a run result into a return value.
§Panics
Panics if the instance instead yielded, with a panic message including the passed message.
Sourcepub fn unwrap_returned(self) -> UntypedRetVal
pub fn unwrap_returned(self) -> UntypedRetVal
Sourcepub fn yielded(self) -> Result<YieldedVal, Error>
pub fn yielded(self) -> Result<YieldedVal, Error>
Try to get a yielded value from a run result, returning Error::InstanceNotYielded
if the
instance instead returned.
Sourcepub fn yielded_ref(&self) -> Result<&YieldedVal, Error>
pub fn yielded_ref(&self) -> Result<&YieldedVal, Error>
Try to get a reference to a yielded value from a run result, returning
Error::InstanceNotYielded
if the instance instead returned.
Sourcepub fn is_yielded(&self) -> bool
pub fn is_yielded(&self) -> bool
Returns true
if the instance yielded.
Sourcepub fn expect_yielded(self, msg: &str) -> YieldedVal
pub fn expect_yielded(self, msg: &str) -> YieldedVal
Unwraps a run result into a yielded value.
§Panics
Panics if the instance instead returned, with a panic message including the passed message.