Skip to main content

nros_platform/board/
mod.rs

1// Phase 212.N.1 — trait surface only; consumers land in 212.N.2+.
2// Suppress `dead_code` workspace-wide until a family driver crate
3// pulls these in. Phase 216.A.1 — `DispatchStrategy` ships ahead of
4// its first consumer (Phase 216.A.2 trait extension), so
5// `unused_imports` joins the allowance.
6#![allow(dead_code, unused_imports)]
7
8//! Board trait family — Phase 212.N.1.
9//!
10//! Platform-agnostic Board taxonomy living in `nros-platform`. The
11//! board crate (`nros-board-{posix,freertos,threadx,…}`) implements
12//! the per-family/per-target surface; user Entry pkgs invoke
13//! `<Board as BoardEntry>::run(setup)` from `main.rs`.
14//!
15//! ## Surface
16//!
17//! ```text
18//! Board: BoardInit + BoardPrint + BoardExit
19//!     │
20//!     ├── TransportBringup: Board    // Ethernet / WiFi / serial / CAN / USB CDC / IVC
21//!     ├── NetworkWait: Board         // carrier / DHCP / link-up gate
22//!     └── BoardEntry: Board {
23//!             fn run<F, E>(setup: F) -> Result<(), E>
24//!             where F: FnOnce(&mut RuntimeCtx) -> Result<(), E>;
25//!         }
26//! ```
27//!
28//! `BoardEntry::run` owns the full boot lifecycle: hardware init →
29//! transport bringup → executor lifecycle → clean exit. The `setup`
30//! callback receives a [`RuntimeCtx`] for overlay (params / remaps /
31//! env) plus the codegen-emitted `run_plan(runtime)` call.
32//!
33//! ## Status
34//!
35//! Phase 212.N.1 ships the trait surface only. Per-board impls
36//! (212.N.2 family driver crates + 212.N.3 tier-1 per-board crates),
37//! codegen (212.N.4 / N.5 — lives in standalone `nros-cli` repo per
38//! CLAUDE.md), and cmake fn rename (212.N.6) follow.
39//!
40//! ## Relationship to existing `nros-board-common::Board*` traits
41//!
42//! The legacy traits in `nros-board-common::board_init`
43//! (`Board`, `BoardInit`, `BoardPrint`, `BoardExit`, `BoardEntry`,
44//! `DirectExec`, `run`) stay as-is during the transition. Phase
45//! 212.N.7 retires the M.5.a FreeRTOS BSP baker and migrates every
46//! Node pkg to the new shape; at that point the legacy
47//! `nros-board-common` traits become `pub use` re-exports of this
48//! module (or get retired entirely if no consumer remains).
49
50pub mod config;
51pub mod dispatch;
52pub mod embassy_entry;
53pub mod entry;
54pub mod exit;
55pub mod init;
56pub mod network;
57pub mod print;
58pub mod rtic_entry;
59pub mod runtime;
60pub mod tier;
61pub mod transport;
62
63pub use config::{BoardConfig, BoardTransportConfig};
64pub use dispatch::DispatchStrategy;
65pub use embassy_entry::EmbassyBoardEntry;
66pub use entry::{BoardEntry, DeployOverlay};
67pub use exit::BoardExit;
68pub use init::BoardInit;
69pub use network::NetworkWait;
70pub use print::BoardPrint;
71pub use rtic_entry::RticBoardEntry;
72pub use runtime::{
73    NodeDispatchRuntime, NullNodeRuntime, RuntimeCtx, RuntimeError, SignaledCallback,
74};
75pub use tier::{TierSpec, freertos_priority_for, posix_nice_for, threadx_priority_for};
76
77/// Phase 214.K.1 — backward-compat alias. The board-side dispatch
78/// sink was renamed `NodeRuntime` → `NodeDispatchRuntime` to
79/// disambiguate from the user-facing `nros::NodeRuntime` metadata
80/// trait. This alias stays for one release cycle so external impl
81/// callers (per-board crates outside the tree) get a clear
82/// deprecation arrow rather than a hard break.
83#[deprecated(
84    note = "renamed to NodeDispatchRuntime — Phase 214.K.1. Update imports + impls within one release cycle."
85)]
86pub use runtime::NodeDispatchRuntime as NodeRuntime;
87pub use transport::TransportBringup;
88
89/// Super-trait every board impl carries (mirrors
90/// `nros-board-common::board_init::Board`).
91///
92/// Blanket-implemented for any type carrying all three contracts;
93/// concrete board crates do NOT impl `Board` directly — they impl
94/// `BoardInit`/`BoardPrint`/`BoardExit` (and the optional mixins).
95pub trait Board: BoardInit + BoardPrint + BoardExit {}
96impl<T: BoardInit + BoardPrint + BoardExit> Board for T {}