orchestrator: Construct ComponentId via From<u8> Replace the ComponentId::new(idx as u8) call in poll_boot_walks with a From<u8> conversion, per review. The const fn new stays for const contexts (test constants). Also assert N <= 256 at compile time in PlatformDriver::new: component ids are u8, so a larger board would wrap them silently. Signed-off-by: Christina Quast <christina.quast@9elements.com>
diff --git a/services/orchestrator/driver/src/driver.rs b/services/orchestrator/driver/src/driver.rs index 20dd800..5f3d9cc 100644 --- a/services/orchestrator/driver/src/driver.rs +++ b/services/orchestrator/driver/src/driver.rs
@@ -54,6 +54,8 @@ impl<B: BoardCapabilities, const N: usize> PlatformDriver<B, N> { pub fn new(board: Board<B, N>) -> Self { + // ComponentId is a u8, so ids for N > 256 components would wrap. + const { assert!(N <= 256) }; Self { board, staged: None, @@ -151,7 +153,7 @@ if !self.watching[idx] { continue; } - let id = ComponentId::new(idx as u8); + let id: ComponentId = (idx as u8).into(); match self.board.boot_watches[idx].poll(now_millis) { WalkVerdict::Waiting { deadline_millis } => { next_deadline_millis = Some(match next_deadline_millis {
diff --git a/services/orchestrator/sm/src/model.rs b/services/orchestrator/sm/src/model.rs index f921269..64ac92b 100644 --- a/services/orchestrator/sm/src/model.rs +++ b/services/orchestrator/sm/src/model.rs
@@ -20,6 +20,12 @@ } } +impl From<u8> for ComponentId { + fn from(value: u8) -> Self { + Self(value) + } +} + /// How a component in the trust chain is classified. The board supplies one /// [`ComponentKind`] per [`ComponentId`] when building the chain. ///