Skip to main content

Controller

Struct Controller 

Source
pub struct Controller(/* private fields */);
Expand description

Lifecycle state machine. Phase, winning action and exit status share one atomic word so a request is published as a whole.

Implementations§

Source§

impl Controller

Source

pub const fn new() -> Self

Source

pub fn state(&self) -> State

Source

pub fn is_running(&self) -> bool

Source

pub fn action(&self) -> Option<Action>

The winning action, once a request was accepted.

Source

pub fn status(&self) -> u8

Exit status of the winning request (meaningful to hosted targets).

Source

pub fn request(&self, action: Action, status: u8) -> Result<(), State>

Trusted request without privilege check, for platform code (for example host signal handlers). Executables use request instead.

A single compare-and-exchange: safe in a POSIX signal handler on targets with native 16-bit atomics. Targets without compare-and-swap use portable-atomic, whose backend the firmware selects. It never allocates or wakes; the supervisor polls Self::state.

Source

pub async fn run<S: Stages>( &self, stages: &mut S, budget: Duration, ) -> Result<(), Error>

Run the pipeline once for the accepted request.

Any stage error moves to State::Failed and stops the pipeline: a failed storage commit never reaches drivers or the final action. Nothing is deallocated on failure. budget bounds quiescence on a monotonic clock.

Source

pub async fn run_forced<S: Stages>( &self, stages: &mut S, budget: Duration, ) -> Result<Option<Error>, Error>

Dangerous: continue to the final action after a quiescence, storage or driver failure. Uncommitted data is lost and live tasks are cut off. Only for trusted platform code that explicitly accepts that loss.

Returns the first skipped stage error if the final action returned.

Trait Implementations§

Source§

impl Default for Controller

Source§

fn default() -> Self

Returns the “default value” for a type. 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, 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.