Skip to main content

State

Struct State 

Source
pub struct State<S: Eq + 'static> { /* private fields */ }
Expand description

Host-owned state resource with explicit current, previous, and pending boundaries.

Implementations§

Source§

impl<S: Eq + 'static> State<S>

Source

pub fn new(initial: S) -> Self

Creates state with initial as Self::current and no pending transition.

Source

pub fn current(&self) -> &S

Active state value after the last committed transition.

Source

pub fn previous(&self) -> Option<&S>

Outgoing value from the most recent committed transition, if any.

Source

pub fn pending(&self) -> Option<&S>

Requested next value awaiting apply, if any.

Source

pub fn transition_tick(&self) -> Option<ChangeTick>

ChangeTick recorded when the last transition committed.

Source

pub fn request(&mut self, next: S) -> Result<(), StateError>

Queues next for commit by apply; idempotent when already current or pending.

Auto Trait Implementations§

§

impl<S> Freeze for State<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for State<S>
where S: RefUnwindSafe,

§

impl<S> Send for State<S>
where S: Send,

§

impl<S> Sync for State<S>
where S: Sync,

§

impl<S> Unpin for State<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for State<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for State<S>
where S: UnwindSafe,

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.