orchestrator: Take ImageSource::size by shared reference The image length is a property of the staged image, not a bus transaction: every realistic source (RAM copy, interposed flash, PLDM transfer) learns it during open and can report a cached value. Taking &self matches embedded_storage::ReadStorage::capacity and leaves the source shareable for size queries; read_at stays &mut self because reads drive the bus, as in embedded_io::Read. Signed-off-by: Christina Quast <christina.quast@9elements.com>
diff --git a/services/orchestrator/driver/src/board.rs b/services/orchestrator/driver/src/board.rs index 81e06cc..bf978f1 100644 --- a/services/orchestrator/driver/src/board.rs +++ b/services/orchestrator/driver/src/board.rs
@@ -17,8 +17,10 @@ /// Idempotent; a later `open` re-stages the image. fn open(&mut self) -> Result<(), Self::Error>; - /// Image length in bytes. - fn size(&mut self) -> Result<usize, Self::Error>; + /// Image length in bytes. Only meaningful after a successful `open`; + /// sources that learn the size during `open` cache it and report the + /// cached value here. + fn size(&self) -> Result<usize, Self::Error>; /// Reads `buf.len()` bytes starting at byte `offset` of the image. fn read_at(&mut self, offset: usize, buf: &mut [u8]) -> Result<(), Self::Error>; @@ -33,7 +35,7 @@ } #[inline(always)] - fn size(&mut self) -> Result<usize, Self::Error> { + fn size(&self) -> Result<usize, Self::Error> { (**self).size() }
diff --git a/services/orchestrator/driver/src/tests.rs b/services/orchestrator/driver/src/tests.rs index f2210c1..0f2bc0e 100644 --- a/services/orchestrator/driver/src/tests.rs +++ b/services/orchestrator/driver/src/tests.rs
@@ -62,7 +62,7 @@ Ok(()) } - fn size(&mut self) -> Result<usize, MemFault> { + fn size(&self) -> Result<usize, MemFault> { Ok(self.data.len()) }