diff --git a/CHANGELOG.md b/CHANGELOG.md index 15f5d0b..8705d23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ## Unreleased +- Add `defmt` attributes to cache types. + ## 3.0.0 17-07-24 - *Breaking:* Map keys are now always passed by reference. This avoids extra cloning and memory use for bigger keys. diff --git a/src/cache/key_pointers.rs b/src/cache/key_pointers.rs index 8719772..d16c5c7 100644 --- a/src/cache/key_pointers.rs +++ b/src/cache/key_pointers.rs @@ -12,6 +12,7 @@ pub(crate) trait KeyPointersCache { } #[derive(Debug)] +#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] pub(crate) struct CachedKeyPointers { key_pointers: [Option<(KEY, NonZeroU32)>; KEYS], } @@ -77,6 +78,7 @@ impl KeyPointersCache for CachedKeyPointers KeyPointersCache for UncachedKeyPointers { diff --git a/src/cache/mod.rs b/src/cache/mod.rs index 7c9ef27..339a0ac 100644 --- a/src/cache/mod.rs +++ b/src/cache/mod.rs @@ -164,6 +164,7 @@ impl> PrivateKeyCacheImpl for &mut T } #[derive(Debug)] +#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] pub(crate) struct DirtTracker { /// Managed from the library code. /// @@ -198,6 +199,7 @@ impl DirtTracker { /// This type of cache doesn't have to be kept around and may be constructed on every api call. /// You could simply pass `&mut NoCache::new()` every time. #[derive(Debug)] +#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] pub struct NoCache { page_states: UncachedPageStates, page_pointers: UncachedPagePointers, @@ -266,6 +268,7 @@ impl PrivateKeyCacheImpl for NoCache { /// /// Make sure the page count is correct. If the number is lower than the actual amount, the code will panic at some point. #[derive(Debug)] +#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] pub struct PageStateCache { dirt_tracker: DirtTracker, page_states: CachedPageStates, @@ -339,6 +342,7 @@ impl PrivateKeyCacheImpl for PageStateCa /// /// Make sure the page count is correct. If the number is lower than the actual amount, the code will panic at some point. #[derive(Debug)] +#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] pub struct PagePointerCache { dirt_tracker: DirtTracker, page_states: CachedPageStates, @@ -417,6 +421,7 @@ impl PrivateKeyCacheImpl for PagePointer /// the chance of a cache hit. /// The keys are cached in a fifo and any time its location is updated in cache it's added to the front. #[derive(Debug)] +#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] pub struct KeyPointerCache { dirt_tracker: DirtTracker, page_states: CachedPageStates, diff --git a/src/cache/page_pointers.rs b/src/cache/page_pointers.rs index ee1b6dc..34f4280 100644 --- a/src/cache/page_pointers.rs +++ b/src/cache/page_pointers.rs @@ -29,6 +29,7 @@ pub(crate) trait PagePointersCache: Debug { // Use NoneZeroU32 because we never store 0's in here (because of the first page marker) // and so Option can make use of the niche so we save bytes +#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] pub(crate) struct CachedPagePointers { after_erased_pointers: [Option; PAGE_COUNT], after_written_pointers: [Option; PAGE_COUNT], @@ -138,6 +139,7 @@ impl PagePointersCache for CachedPagePointers { pages: [Option; PAGE_COUNT], } @@ -55,6 +56,7 @@ impl PageStatesCache for CachedPageStates { } #[derive(Debug, Default)] +#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] pub(crate) struct UncachedPageStates; impl PageStatesCache for UncachedPageStates { diff --git a/src/lib.rs b/src/lib.rs index 3b9d8bc..567c4ab 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -329,6 +329,7 @@ async fn partial_close_page( /// The state of a page #[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] enum PageState { /// This page was fully written and has now been sealed Closed,