diff --git a/src/storage.rs b/src/storage.rs index 6546269..d2e8629 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -132,6 +132,20 @@ where } } +pub trait StorageIterate { + type Error: Debug; + type Entry: StorageEntry; + type Entries<'a>: Iterator> + where + Self: 'a; + + fn entries(&self) -> Result, Self::Error>; +} + +pub trait StorageEntry { + fn name(&self) -> &str; +} + #[derive(Debug)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum StorageError { @@ -264,6 +278,21 @@ where } } +impl StorageIterate for StorageImpl +where + S: SerDe, + R: StorageIterate, +{ + type Error = R::Error; + type Entry = R::Entry; + type Entries<'a> = R::Entries<'a> + where Self: 'a; + + fn entries<'a>(&'a self) -> Result, Self::Error> { + self.raw_storage.entries() + } +} + struct Entry<'a> { name: &'a str, value: &'a dyn Any,