Enum State

Source
pub enum State {
    Ready,
    Running,
    Faulted {
        details: FaultDetails,
        siginfo: siginfo_t,
        context: UContext,
    },
    Terminating {
        details: TerminationDetails,
    },
    Terminated,
    Yielding {
        val: YieldedVal,
        expecting: Box<dyn Any>,
    },
    Yielded {
        expecting: Box<dyn Any>,
    },
    Transitioning,
}
Expand description

The representation of a Lucet instance’s state machine.

Variants§

§

Ready

The instance is ready to run.

Transitions to Running when the instance is run, or to Ready when it’s reset.

§

Running

The instance is running.

Transitions to Ready when the guest function returns normally, or to Faulted, Terminating, or Yielding if the instance faults, terminates, or yields.

§

Faulted

The instance has faulted, potentially fatally.

Transitions to Faulted when filling in additional fault details, to Running if re-running a non-fatally faulted instance, or to Ready when the instance is reset.

Fields

§siginfo: siginfo_t
§context: UContext
§

Terminating

The instance is in the process of terminating.

Transitions only to Terminated; the TerminationDetails are always extracted into a RunResult before anything else happens to the instance.

Fields

§

Terminated

The instance has terminated, and must be reset before running again.

Transitions to Ready if the instance is reset.

§

Yielding

The instance is in the process of yielding.

Transitions only to Yielded; the YieldedVal is always extracted into a RunResult before anything else happens to the instance.

Fields

§expecting: Box<dyn Any>

A phantom value carrying the type of the expected resumption value.

Concretely, this should only ever be Box<PhantomData<R>> where R is the type the guest expects upon resumption.

§

Yielded

The instance has yielded.

Transitions to Running if the instance is resumed, or to Ready if the instance is reset.

Fields

§expecting: Box<dyn Any>

A phantom value carrying the type of the expected resumption value.

Concretely, this should only ever be Box<PhantomData<R>> where R is the type the guest expects upon resumption.

§

Transitioning

A placeholder state used with std::mem::replace() when a new state must be constructed by moving values out of an old state.

This is used so that we do not need a Clone impl for this type, which would add unnecessary constraints to the types of values instances could yield or terminate with.

It is an error for this state to appear outside of a transition between other states.

Implementations§

Source§

impl State

Source

pub fn is_ready(&self) -> bool

Source

pub fn is_running(&self) -> bool

Source

pub fn is_faulted(&self) -> bool

Source

pub fn is_fatal(&self) -> bool

Source

pub fn is_terminated(&self) -> bool

Source

pub fn is_yielded(&self) -> bool

Trait Implementations§

Source§

impl Display for State

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for State

§

impl !RefUnwindSafe for State

§

impl !Send for State

§

impl !Sync for State

§

impl Unpin for State

§

impl !UnwindSafe for State

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.