Skip to main content

nros_platform/board/
transport.rs

1//! [`TransportBringup`] — Phase 212.N.1 mixin.
2//!
3//! Per-board transport bringup. Brings the link layer (Ethernet,
4//! WiFi, CAN, serial UART, USB CDC, IVC, …) up to the point where
5//! the executor's RMW can open sessions. Called by
6//! `BoardEntry::run` after `BoardInit::init_hardware` and before
7//! `NetworkWait::wait_link_up` (if implemented).
8//!
9//! ## Composition
10//!
11//! Boards pick one or several transports at the type system level
12//! by implementing `TransportBringup` once per concrete board. A
13//! board with multiple transports composes via an internal helper
14//! (e.g. a `MultiTransport` newtype) rather than via blanket impls,
15//! since each transport's bringup is sequential and order-sensitive
16//! (`init_link` before `link_up`, sockets opened only after link).
17//!
18//! ## Status
19//!
20//! Phase 212.N.1 — trait surface only. 212.N.2 family driver crates
21//! provide concrete impls.
22
23/// Per-board transport bringup contract.
24pub trait TransportBringup: super::Board {
25    /// Bring the link layer up. Returns when the link is at L2
26    /// (Ethernet frames flow / WiFi associated / UART open at
27    /// baud / CAN bus listening) but BEFORE any L3/IP state. The
28    /// [`super::NetworkWait`] mixin handles DHCP / link-up gating.
29    ///
30    /// Returning `Err` ends boot via [`super::BoardExit::exit_failure`].
31    fn init_transport() -> Result<(), TransportError>;
32}
33
34/// Transport bringup failure mode.
35///
36/// Kept minimal on purpose — boards surface the gritty detail (NIC
37/// register state, WiFi association code, UART error register)
38/// through their own logging. The error returned by
39/// [`TransportBringup::init_transport`] is a coarse signal to
40/// `BoardEntry::run` that boot can't proceed.
41#[derive(Debug, Clone, Copy, PartialEq, Eq)]
42#[non_exhaustive]
43pub enum TransportError {
44    /// PHY didn't reach the linked state in the board's deadline.
45    LinkDown,
46    /// Driver init failed (NIC reset hung, WiFi chip enumeration
47    /// failed, UART couldn't claim its pins).
48    DriverInit,
49    /// Transport hardware absent or not enabled at the board level.
50    NotPresent,
51    /// Board-specific failure not covered by the above. Boards
52    /// using this should also log a richer message via
53    /// [`super::BoardPrint::println`] before returning.
54    Other,
55}