(&mut self, decoder: &mut D) -> Result<(), DecodeError>
}
CuTask -- Freezable : "typically implements"
```
--------------------------------
### Development Workflow Mapping Diagram
Source: https://deepwiki.com/copper-project/copper-rs/4-development-guide
A Mermaid diagram illustrating the relationship between entry points, automation scripts, and code entities.
```mermaid
graph TD
subgraph "Entry Points"
NewApp["cargo cunew"] -- "Uses" --> Tmpl["templates/cu_project"]
Workflow["Justfile / CI"] -- "Invokes" --> Scripts["support/ci/"]
end
subgraph "Automation Logic"
Scripts -- "Filters" --> Excludes["support/ci/workspace_excludes.py"]
Scripts -- "Validates" --> EmbCrates["support/ci/embedded_crates.py"]
Scripts -- "Tests" --> CovScript["support/ci/run_coverage.sh"]
end
subgraph "Code Entities"
Excludes -.-> RootCargo["/Cargo.toml"]
EmbCrates -.-> Firmwares["examples/cu_rp2350_skeleton"]
CovScript -.-> ProfData["target/llvm-cov/"]
end
```
--------------------------------
### Enable Simulation Mode in #[copper_runtime]
Source: https://deepwiki.com/copper-project/copper-rs/6.3-simulation-and-re-simulation
Set sim_mode to true within the #[copper_runtime] attribute to enable simulation capabilities for the application struct.
```rust
#[copper_runtime(config = "copperconfig.ron", sim_mode = true)]
struct MySimulatedApp {}
```
--------------------------------
### Data Flow for Component Discovery (Mermaid flowchart)
Source: https://deepwiki.com/copper-project/copper-rs/4.4-project-templates
Mermaid flowchart showing how the catalog index references component crates, which implement bridges and define code entities like CuBdshotBridge and EscCommand.
```mermaid
flowchart TD
Catalog["Catalog Index (RON)"] -- "references" --> Crate["Component Crate (e.g., cu_bdshot)"]
Crate -- "implements" --> Bridge["CuBridge Implementation"]
subgraph "Code Entity Space"
BridgeNode["struct CuBdshotBridge"]
ChannelSet["trait BridgeChannelSet"]
MsgNode["struct EscCommand"]
ConfigNode["struct BridgeChannelConfig"]
end
Bridge -.-> BridgeNode
BridgeNode -- "defines" --> ChannelSet
BridgeNode -- "processes" --> MsgNode
BridgeNode -- "configured by" --> ConfigNode
```
--------------------------------
### CuMsg class diagram (CuStampedData, CuMsgMetadata, Tov)
Source: https://deepwiki.com/copper-project/copper-rs/1.1-core-concepts
Mermaid class diagram showing the structure of CuStampedData (aliased as CuMsg) with payload, time-of-validity (Tov), and metadata. Includes CuMsgMetadata with process_time, status_txt, and origin, and the Tov enumeration with None, Time, and TimeRange variants.
```mermaid
classDiagram
class CuStampedData~T, M~ {
payload: Option~T~
tov: Tov
metadata: M
}
class CuMsgMetadata {
process_time: PartialCuTimeRange
status_txt: CuCompactString
origin: Option~CuMsgOrigin~
}
class Tov {
<>
None
Time(CuTime)
TimeRange(CuTimeRange)
}
CuStampedData --> CuMsgMetadata : Metadata = M
CuStampedData --> Tov
```
--------------------------------
### Flight Controller Mapping
Source: https://deepwiki.com/copper-project/copper-rs/5-examples
A Mermaid flowchart showing the hardware and code entity relationships for the Flight Controller application on STM32H7 hardware.
```mermaid
flowchart TD
subgraph "Hardware Entities"
MCU["STM32H7 (MicoAirH743)"]
DWT["DWT Cycle Counter"]
end
subgraph "Code Entities"
Entry["#[entry] main()"]
Clock["build_clock()"]
AppStruct["#[copper_runtime] FlightControllerApp"]
Resources["FlightControllerApp::prepare_resources()"]
end
MCU --- Entry
DWT --- Clock
Entry --> Resources
Resources --> AppStruct
AppStruct --> Run["CuApplication::run()"]
```
--------------------------------
### Platform Abstraction Layer Mermaid Diagram
Source: https://deepwiki.com/copper-project/copper-rs/6-advanced-topics
A visual representation of the interaction between the high-level Copper Runtime and platform-specific code entities like RobotClock and ResourceManager.
```mermaid
graph TD
subgraph "Natural Language Space"
Runtime["Copper Runtime"]
Clock["System Clock"]
HAL["Hardware Abstraction"]
end
subgraph "Code Entity Space"
CU_RUNTIME["CuRuntime"]
ROBOT_CLOCK["RobotClock"]
RES_MANAGER["ResourceManager"]
SOFT_RATATUI["soft_ratatui"]
end
CU_RUNTIME -- "Queries" --> ROBOT_CLOCK
CU_RUNTIME -- "Requests HAL" --> RES_MANAGER
RES_MANAGER -- "Renders TUI" --> SOFT_RATATUI
```
--------------------------------
### Task Execution Data Flow Diagram
Source: https://deepwiki.com/copper-project/copper-rs/7-glossary
A Mermaid diagram illustrating the mapping between natural language task execution concepts and the corresponding CuRuntime code entities.
```mermaid
graph LR
subgraph "Natural Language Space"
A["Task Execution"]
B["Message Passing"]
C["Logging"]
end
subgraph "Code Entity Space"
A --> D["CuTask::process()"]
D --> E["InputMsg<'a, P>"]
D --> F["OutputMsg<'a, P>"]
E --> G["CopperList"]
F --> G
G --> H["UnifiedLogWrite"]
H --> I["MmapUnifiedLogger"]
end
```
--------------------------------
### Re-simulation Data Flow Diagram
Source: https://deepwiki.com/copper-project/copper-rs/6-advanced-topics
Mermaid diagram showing how CuDebugSession interacts with recorded logs and application logic, including UnifiedLogRead, CuApp, and SimOverride components.
```mermaid
graph TD
subgraph "Natural Language Space"
Log["Recorded Log File"]
Session["Debug Session"]
App["Robot Application"]
end
subgraph "Code Entity Space"
UNIFIED_LOG["UnifiedLogRead"]
DEBUG_SESSION["CuDebugSession"]
CU_APP["CuApp"]
SIM_OVERRIDE["SimOverride"]
end
UNIFIED_LOG -- "Provides Data" --> DEBUG_SESSION
DEBUG_SESSION -- "Drives" --> CU_APP
CU_APP -- "Uses" --> SIM_OVERRIDE
SIM_OVERRIDE -- "Injects Inputs" --> DEBUG_SESSION
```
--------------------------------
### Clock Calibration Sequence Diagram
Source: https://deepwiki.com/copper-project/copper-rs/2.4-clock-and-timing
A sequence diagram illustrating the calibration process between the RobotClock, the calibration function, the hardware counter, and the reference clock.
```mermaid
sequenceDiagram
participant C as RobotClock
participant Cal as calibration::calibrate
participant HW as Hardware Counter
participant RTC as Reference Clock (RTC)
C->>Cal: calibrate(read_raw_counter, read_rtc_ns, sleep_ns)
Cal->>HW: read_raw_counter (Start)
Cal->>RTC: read_rtc_ns (Start)
Cal->>Cal: sleep_ns(10ms)
Cal->>HW: read_raw_counter (End)
Cal->>RTC: read_rtc_ns (End)
Note over Cal: freq = (delta_counter * 1e9) / delta_rtc_ns
Cal->>Cal: Store calibration constants
```
--------------------------------
### Cargo.toml profile.release and hot-path overrides
Source: https://deepwiki.com/copper-project/copper-rs/6.1-performance-optimization
Defines release optimizations with debug info and overrides for hot-path packages (candle-core and rayon) to always compile with opt-level 3.
```toml
[profile.release]
debug = 2
# Application hot-path overrides
[profile.dev.package.candle-core]
opt-level = 3
[profile.dev.package.rayon]
opt-level = 3
```