aboutsummaryrefslogtreecommitdiff
path: root/embassy-time/src
diff options
context:
space:
mode:
authorRalph Ursprung <[email protected]>2025-07-28 15:37:34 +0200
committerRalph Ursprung <[email protected]>2025-07-28 15:44:21 +0200
commit98595f659c309703aab411b6b3be7579b6e93c5d (patch)
treec2c138d3d0e2e1348b66ee31dae9b2f772d801d1 /embassy-time/src
parent8f64a14bebe711962af0136a5acd2b3cef509402 (diff)
`embassy-time`: add missing `Debug` & `defmt::Format` derives
`defmt::Format` is *not* implemented for `MockDriver` and `InnerMockDriver` because the former contains the latter and the latter is using `Queue` from `embassy-time-queue-utils` which so far does not have a `defmt` dependency. since this is just a mock driver it shouldn't be relevant if it has no `defmt::Format` impl.
Diffstat (limited to 'embassy-time/src')
-rw-r--r--embassy-time/src/delay.rs3
-rw-r--r--embassy-time/src/driver_mock.rs2
-rw-r--r--embassy-time/src/driver_std.rs6
-rw-r--r--embassy-time/src/driver_wasm.rs6
-rw-r--r--embassy-time/src/lib.rs1
-rw-r--r--embassy-time/src/timer.rs6
6 files changed, 23 insertions, 1 deletions
diff --git a/embassy-time/src/delay.rs b/embassy-time/src/delay.rs
index f77859d4a..67345f726 100644
--- a/embassy-time/src/delay.rs
+++ b/embassy-time/src/delay.rs
@@ -13,7 +13,8 @@ pub fn block_for(duration: Duration) {
13/// the amount provided, but accuracy can be affected by many factors, including interrupt usage. 13/// the amount provided, but accuracy can be affected by many factors, including interrupt usage.
14/// Make sure to use a suitable tick rate for your use case. The tick rate is defined by the currently 14/// Make sure to use a suitable tick rate for your use case. The tick rate is defined by the currently
15/// active driver. 15/// active driver.
16#[derive(Clone)] 16#[derive(Clone, Debug)]
17#[cfg_attr(feature = "defmt", derive(defmt::Format))]
17pub struct Delay; 18pub struct Delay;
18 19
19impl embedded_hal_1::delay::DelayNs for Delay { 20impl embedded_hal_1::delay::DelayNs for Delay {
diff --git a/embassy-time/src/driver_mock.rs b/embassy-time/src/driver_mock.rs
index bb1961bf2..bcde2a6c9 100644
--- a/embassy-time/src/driver_mock.rs
+++ b/embassy-time/src/driver_mock.rs
@@ -28,6 +28,7 @@ use crate::{Duration, Instant};
28/// assert_eq!(true, has_a_second_passed(reference)); 28/// assert_eq!(true, has_a_second_passed(reference));
29/// } 29/// }
30/// ``` 30/// ```
31#[derive(Debug)]
31pub struct MockDriver(CsMutex<RefCell<InnerMockDriver>>); 32pub struct MockDriver(CsMutex<RefCell<InnerMockDriver>>);
32 33
33embassy_time_driver::time_driver_impl!(static DRIVER: MockDriver = MockDriver::new()); 34embassy_time_driver::time_driver_impl!(static DRIVER: MockDriver = MockDriver::new());
@@ -80,6 +81,7 @@ impl Driver for MockDriver {
80 } 81 }
81} 82}
82 83
84#[derive(Debug)]
83struct InnerMockDriver { 85struct InnerMockDriver {
84 now: Instant, 86 now: Instant,
85 queue: Queue, 87 queue: Queue,
diff --git a/embassy-time/src/driver_std.rs b/embassy-time/src/driver_std.rs
index 87d7ef7eb..a77eed75e 100644
--- a/embassy-time/src/driver_std.rs
+++ b/embassy-time/src/driver_std.rs
@@ -5,11 +5,15 @@ use std::time::{Duration as StdDuration, Instant as StdInstant};
5use embassy_time_driver::Driver; 5use embassy_time_driver::Driver;
6use embassy_time_queue_utils::Queue; 6use embassy_time_queue_utils::Queue;
7 7
8#[derive(Debug)]
9#[cfg_attr(feature = "defmt", derive(defmt::Format))]
8struct TimeDriver { 10struct TimeDriver {
9 signaler: Signaler, 11 signaler: Signaler,
10 inner: Mutex<Inner>, 12 inner: Mutex<Inner>,
11} 13}
12 14
15#[derive(Debug)]
16#[cfg_attr(feature = "defmt", derive(defmt::Format))]
13struct Inner { 17struct Inner {
14 zero_instant: Option<StdInstant>, 18 zero_instant: Option<StdInstant>,
15 queue: Queue, 19 queue: Queue,
@@ -64,6 +68,8 @@ fn alarm_thread() {
64 } 68 }
65} 69}
66 70
71#[derive(Debug)]
72#[cfg_attr(feature = "defmt", derive(defmt::Format))]
67struct Signaler { 73struct Signaler {
68 mutex: Mutex<bool>, 74 mutex: Mutex<bool>,
69 condvar: Condvar, 75 condvar: Condvar,
diff --git a/embassy-time/src/driver_wasm.rs b/embassy-time/src/driver_wasm.rs
index e3207691a..646ce170e 100644
--- a/embassy-time/src/driver_wasm.rs
+++ b/embassy-time/src/driver_wasm.rs
@@ -5,6 +5,8 @@ use embassy_time_queue_utils::Queue;
5use wasm_bindgen::prelude::*; 5use wasm_bindgen::prelude::*;
6use wasm_timer::Instant as StdInstant; 6use wasm_timer::Instant as StdInstant;
7 7
8#[derive(Debug)]
9#[cfg_attr(feature = "defmt", derive(defmt::Format))]
8struct AlarmState { 10struct AlarmState {
9 token: Option<f64>, 11 token: Option<f64>,
10} 12}
@@ -21,10 +23,14 @@ extern "C" {
21 fn clearTimeout(token: f64); 23 fn clearTimeout(token: f64);
22} 24}
23 25
26#[derive(Debug)]
27#[cfg_attr(feature = "defmt", derive(defmt::Format))]
24struct TimeDriver { 28struct TimeDriver {
25 inner: Mutex<Inner>, 29 inner: Mutex<Inner>,
26} 30}
27 31
32#[derive(Debug)]
33#[cfg_attr(feature = "defmt", derive(defmt::Format))]
28struct Inner { 34struct Inner {
29 alarm: AlarmState, 35 alarm: AlarmState,
30 zero_instant: Option<StdInstant>, 36 zero_instant: Option<StdInstant>,
diff --git a/embassy-time/src/lib.rs b/embassy-time/src/lib.rs
index 80a359413..77f4b344d 100644
--- a/embassy-time/src/lib.rs
+++ b/embassy-time/src/lib.rs
@@ -3,6 +3,7 @@
3#![doc = include_str!("../README.md")] 3#![doc = include_str!("../README.md")]
4#![allow(clippy::new_without_default)] 4#![allow(clippy::new_without_default)]
5#![warn(missing_docs)] 5#![warn(missing_docs)]
6#![deny(missing_debug_implementations)]
6 7
7//! ## Feature flags 8//! ## Feature flags
8#![doc = document_features::document_features!(feature_label = r#"<span class="stab portability"><code>{feature}</code></span>"#)] 9#![doc = document_features::document_features!(feature_label = r#"<span class="stab portability"><code>{feature}</code></span>"#)]
diff --git a/embassy-time/src/timer.rs b/embassy-time/src/timer.rs
index d3f1e1621..54bb9b6d8 100644
--- a/embassy-time/src/timer.rs
+++ b/embassy-time/src/timer.rs
@@ -66,6 +66,8 @@ impl<F: Future> WithTimeout for F {
66 66
67/// Future for the [`with_timeout`] and [`with_deadline`] functions. 67/// Future for the [`with_timeout`] and [`with_deadline`] functions.
68#[must_use = "futures do nothing unless you `.await` or poll them"] 68#[must_use = "futures do nothing unless you `.await` or poll them"]
69#[derive(Debug)]
70#[cfg_attr(feature = "defmt", derive(defmt::Format))]
69pub struct TimeoutFuture<F> { 71pub struct TimeoutFuture<F> {
70 timer: Timer, 72 timer: Timer,
71 fut: F, 73 fut: F,
@@ -92,6 +94,8 @@ impl<F: Future> Future for TimeoutFuture<F> {
92 94
93/// A future that completes at a specified [Instant](struct.Instant.html). 95/// A future that completes at a specified [Instant](struct.Instant.html).
94#[must_use = "futures do nothing unless you `.await` or poll them"] 96#[must_use = "futures do nothing unless you `.await` or poll them"]
97#[derive(Debug)]
98#[cfg_attr(feature = "defmt", derive(defmt::Format))]
95pub struct Timer { 99pub struct Timer {
96 expires_at: Instant, 100 expires_at: Instant,
97 yielded_once: bool, 101 yielded_once: bool,
@@ -227,6 +231,8 @@ impl Future for Timer {
227/// ## Cancel safety 231/// ## Cancel safety
228/// It is safe to cancel waiting for the next tick, 232/// It is safe to cancel waiting for the next tick,
229/// meaning no tick is lost if the Future is dropped. 233/// meaning no tick is lost if the Future is dropped.
234#[derive(Debug)]
235#[cfg_attr(feature = "defmt", derive(defmt::Format))]
230pub struct Ticker { 236pub struct Ticker {
231 expires_at: Instant, 237 expires_at: Instant,
232 duration: Duration, 238 duration: Duration,