Skip to main content

CuSimAppLifecycle

Struct CuSimAppLifecycle 

Source
pub struct CuSimAppLifecycle<S, L, A, State = Initialized> { /* private fields */ }
Expand description

Compile-time enforced lifecycle for a CuSimApplication.

Simulation counterpart of CuAppLifecycle: same states and transitions, with each transition threading the sim_callback the simulation runtime requires. Replay primitives (replay_recorded_copperlist, restore_keyframe) are framework-level and stay on the raw traits.

Implementations§

Source§

impl<S, L, A, State> CuSimAppLifecycle<S, L, A, State>

Source

pub fn inner(&self) -> &A

Read-only access to the wrapped application.

Source

pub fn into_inner(self) -> A

Consumes the wrapper and returns the application, dropping the compile-time lifecycle tracking.

Source§

impl<S, L, A> CuSimAppLifecycle<S, L, A>
where S: SectionStorage, L: UnifiedLogWrite<S> + 'static, A: CuSimApplication<S, L>,

Source

pub fn new(app: A) -> CuSimAppLifecycle<S, L, A>

Wraps a freshly built simulation application in the Initialized state.

Source§

impl<S, L, A, State> CuSimAppLifecycle<S, L, A, State>
where S: SectionStorage, L: UnifiedLogWrite<S> + 'static, A: CuSimApplication<S, L>, State: Startable,

Source

pub fn start( self, sim_callback: &mut impl for<'z> FnMut(<A as CuSimApplication<S, L>>::Step<'z>) -> SimOverride, ) -> Result<CuSimAppLifecycle<S, L, A, Running>, SimLifecycleError<S, L, A>>

Starts all tasks, transitioning to Running.

On failure the application may be partially started; it is returned typed Faulted inside the error so it can be cleaned up.

Source

pub fn run_until_shutdown( self, sim_callback: &mut impl for<'z> FnMut(<A as CuSimApplication<S, L>>::Step<'z>) -> SimOverride, ) -> Result<CuSimAppLifecycle<S, L, A, Stopped>, SimLifecycleError<S, L, A>>

Runs the full lifecycle (start, iterate until shutdown, stop), transitioning to Stopped on success.

Source§

impl<S, L, A> CuSimAppLifecycle<S, L, A, Running>
where S: SectionStorage, L: UnifiedLogWrite<S> + 'static, A: CuSimApplication<S, L>,

Source

pub fn run_one_iteration( &mut self, sim_callback: &mut impl for<'z> FnMut(<A as CuSimApplication<S, L>>::Step<'z>) -> SimOverride, ) -> Result<(), CuError>

Executes one iteration of the runtime. An iteration error does not change the lifecycle state: the caller decides whether to keep iterating or stop.

Source§

impl<S, L, A, State> CuSimAppLifecycle<S, L, A, State>
where S: SectionStorage, L: UnifiedLogWrite<S> + 'static, A: CuSimApplication<S, L>, State: Stoppable,

Source

pub fn stop( self, sim_callback: &mut impl for<'z> FnMut(<A as CuSimApplication<S, L>>::Step<'z>) -> SimOverride, ) -> Result<CuSimAppLifecycle<S, L, A, Stopped>, SimLifecycleError<S, L, A>>

Stops all tasks, transitioning to Stopped. From Faulted this is a best-effort cleanup. On failure the application is handed back typed Faulted again.

Trait Implementations§

Source§

impl<S, L, A> CuSimApplication<S, L> for CuSimAppLifecycle<S, L, A>
where S: SectionStorage, L: UnifiedLogWrite<S> + 'static, A: CuSimApplication<S, L>,

Available on crate feature std only.

Legacy escape hatch mirroring the CuApplication impl on CuAppLifecycle: pre-typestate simulation code compiles unchanged against what build() returns and only picks up deprecation warnings.

Source§

type Step<'z> = <A as CuSimApplication<S, L>>::Step<'z>

The type representing a simulation step that can be overridden
Source§

fn get_original_config() -> String

Returns the original configuration as a string, typically loaded from a RON file. This configuration represents the default settings for the application before any overrides.
Source§

fn mission_id() -> Option<&'static str>

Returns the mission id this generated application is bound to, when applicable.
Source§

fn start_all_tasks( &mut self, sim_callback: &mut impl for<'z> FnMut(<CuSimAppLifecycle<S, L, A> as CuSimApplication<S, L>>::Step<'z>) -> SimOverride, ) -> Result<(), CuError>

👎Deprecated since 1.2.0:

use the typed transition start() on the handle returned by build()

Starts all tasks managed by the application/runtime in simulation mode. Read more
Source§

fn run_one_iteration( &mut self, sim_callback: &mut impl for<'z> FnMut(<CuSimAppLifecycle<S, L, A> as CuSimApplication<S, L>>::Step<'z>) -> SimOverride, ) -> Result<(), CuError>

👎Deprecated since 1.2.0:

use run_one_iteration() on the Running handle from build()?.start()?

Executes a single iteration of copper-generated runtime in simulation mode. Read more
Source§

fn run( &mut self, sim_callback: &mut impl for<'z> FnMut(<CuSimAppLifecycle<S, L, A> as CuSimApplication<S, L>>::Step<'z>) -> SimOverride, ) -> Result<(), CuError>

👎Deprecated since 1.2.0:

use the typed transition run_until_shutdown() on the handle returned by build()

Runs indefinitely looping over run_one_iteration in simulation mode Read more
Source§

fn stop_all_tasks( &mut self, sim_callback: &mut impl for<'z> FnMut(<CuSimAppLifecycle<S, L, A> as CuSimApplication<S, L>>::Step<'z>) -> SimOverride, ) -> Result<(), CuError>

👎Deprecated since 1.2.0:

use the typed transition stop() on the Running handle

Stops all tasks managed by the application/runtime in simulation mode. Read more
Source§

fn restore_keyframe(&mut self, freezer: &KeyFrame) -> Result<(), CuError>

Restore all tasks from the given frozen state
Source§

impl<S, L, A, State> Debug for CuSimAppLifecycle<S, L, A, State>

Available on crate feature std only.
Source§

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

Formats the value using the given formatter. Read more
Source§

impl<S, L, A, State> Deref for CuSimAppLifecycle<S, L, A, State>

Available on crate feature std only.

Read access to the wrapped application in every lifecycle state.

Source§

type Target = A

The resulting type after dereferencing.
Source§

fn deref(&self) -> &A

Dereferences the value.
Source§

impl<S, L, A> DerefMut for CuSimAppLifecycle<S, L, A>

Available on crate feature std only.

Mutable access only before the application is started, mirroring CuAppLifecycle.

Source§

fn deref_mut(&mut self) -> &mut A

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<S, L, A, State> Freeze for CuSimAppLifecycle<S, L, A, State>

§

impl<S, L, A, State> RefUnwindSafe for CuSimAppLifecycle<S, L, A, State>

§

impl<S, L, A, State> Send for CuSimAppLifecycle<S, L, A, State>
where A: Send, S: Send, L: Send, State: Send,

§

impl<S, L, A, State> Sync for CuSimAppLifecycle<S, L, A, State>
where A: Sync, S: Sync, L: Sync, State: Sync,

§

impl<S, L, A, State> Unpin for CuSimAppLifecycle<S, L, A, State>
where S: Unpin, L: Unpin, State: Unpin,

§

impl<S, L, A, State> UnsafeUnpin for CuSimAppLifecycle<S, L, A, State>

§

impl<S, L, A, State> UnwindSafe for CuSimAppLifecycle<S, L, A, State>
where A: UnwindSafe, S: UnwindSafe, L: UnwindSafe, State: 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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSend for T
where T: Any + Send,

§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<A> Is for A
where A: Any,

§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
Source§

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

Source§

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

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.