Trait CuApplication

Source
pub trait CuApplication {
    // Required methods
    fn get_original_config() -> String;
    fn new(
        clock: RobotClock,
        unified_logger: Arc<Mutex<UnifiedLoggerWrite>>,
        config_override: Option<CuConfig>,
    ) -> Result<Self, CuError>
       where Self: Sized;
    fn start_all_tasks(&mut self) -> Result<(), CuError>;
    fn run_one_iteration(&mut self) -> Result<(), CuError>;
    fn run(&mut self) -> Result<(), CuError>;
    fn stop_all_tasks(&mut self) -> Result<(), CuError>;
    fn restore_keyframe(&mut self, freezer: &KeyFrame) -> Result<(), CuError>;
}
Expand description

A trait that defines the structure and behavior of a CuApplication.

CuApplication is the normal, running on robot version of an application and its runtime.

The CuApplication trait outlines the necessary functions required for managing an application lifecycle, including configuration management, initialization, task execution, and runtime control. It is meant to be implemented by types that represent specific applications, providing them with unified control and execution features.

Required Methods§

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 new( clock: RobotClock, unified_logger: Arc<Mutex<UnifiedLoggerWrite>>, config_override: Option<CuConfig>, ) -> Result<Self, CuError>
where Self: Sized,

Creates a new application.

§Arguments
  • clock - A RobotClock instance to be used for time-related operations in the implementing struct.
  • unified_logger - A thread-safe, shared reference to UnifiedLoggerWrite, enabling logging functionalities.
  • config_override - An optional CuConfig instance that allows overriding the default configuration values.
    • If Some, the provided configuration will be used.
    • If None, the default configuration will be applied.
§Returns

A result containing either:

  • An instantiated object of the implementing type (Self), or
  • A CuResult error in case of failure during initialization.
Source

fn start_all_tasks(&mut self) -> Result<(), CuError>

Starts all tasks managed by the application/runtime.

§Returns
  • Ok(()) - If all tasks are started successfully.
  • Err(CuResult) - If an error occurs while attempting to start one or more tasks.
Source

fn run_one_iteration(&mut self) -> Result<(), CuError>

Executes a single iteration of copper-generated runtime (generating and logging one copperlist)

§Returns
  • CuResult<()> - Returns Ok(()) if the iteration completes successfully, or an error wrapped in CuResult if something goes wrong during execution.
Source

fn run(&mut self) -> Result<(), CuError>

Runs indefinitely looping over run_one_iteration

§Returns

Returns a CuResult<()>, which indicates the success or failure of the operation.

  • On success, the result is Ok(()).
  • On failure, an appropriate error wrapped in CuResult is returned.
Source

fn stop_all_tasks(&mut self) -> Result<(), CuError>

Stops all tasks managed by the application/runtime.

§Returns

Returns a CuResult<()>, which indicates the success or failure of the operation.

  • On success, the result is Ok(()).
  • On failure, an appropriate error wrapped in CuResult is returned.
Source

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

Restore all tasks from the given frozen state

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§