Enum RunResult

Source
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

Source

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.

Source

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.

Source

pub fn is_returned(&self) -> bool

Returns true if the instance returned a value.

Source

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.

Source

pub fn unwrap_returned(self) -> UntypedRetVal

Unwraps a run result into a returned value.

§Panics

Panics if the instance instead yielded.

Source

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.

Source

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.

Source

pub fn is_yielded(&self) -> bool

Returns true if the instance yielded.

Source

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.

Source

pub fn unwrap_yielded(self) -> YieldedVal

Unwraps a run result into a yielded value.

§Panics

Panics if the instance instead returned.

Trait Implementations§

Source§

impl Debug for RunResult

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.