From 1a86e288a7de3dbb0583704f91f302a6591187b9 Mon Sep 17 00:00:00 2001 From: Alexander van Saase Date: Fri, 19 Jul 2024 21:06:37 +0200 Subject: [PATCH 1/2] Make capacity async and fallible --- embedded-storage-async/src/nor_flash.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embedded-storage-async/src/nor_flash.rs b/embedded-storage-async/src/nor_flash.rs index d868640..3fe4b35 100644 --- a/embedded-storage-async/src/nor_flash.rs +++ b/embedded-storage-async/src/nor_flash.rs @@ -19,7 +19,7 @@ pub trait ReadNorFlash: ErrorType { async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error>; /// The capacity of the peripheral in bytes. - fn capacity(&self) -> usize; + async fn capacity(&self) -> Result; } /// NOR flash trait. From 9bf91f16d71e3f05a8cc88b47f28a7a6c811769c Mon Sep 17 00:00:00 2001 From: Alexander van Saase Date: Fri, 19 Jul 2024 21:13:47 +0200 Subject: [PATCH 2/2] Add to docs --- embedded-storage-async/src/nor_flash.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/embedded-storage-async/src/nor_flash.rs b/embedded-storage-async/src/nor_flash.rs index 3fe4b35..8387cde 100644 --- a/embedded-storage-async/src/nor_flash.rs +++ b/embedded-storage-async/src/nor_flash.rs @@ -19,6 +19,10 @@ pub trait ReadNorFlash: ErrorType { async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error>; /// The capacity of the peripheral in bytes. + /// + /// # Errors + /// + /// Returns an error if the IO operation fails. async fn capacity(&self) -> Result; }