aboutsummaryrefslogtreecommitdiff
path: root/embassy-sync/src
diff options
context:
space:
mode:
authorCurly <[email protected]>2025-08-19 22:30:53 -0700
committerCurly <[email protected]>2025-08-19 22:36:49 -0700
commit368738bef44dbba1a178383d878a6d9423b1ccd9 (patch)
tree4c375e7ec4615e6dee9fda837584067d19b7caf6 /embassy-sync/src
parenta5cb04bdab602bc3bd056d254a9d61cad55bd967 (diff)
chore: add more `Debug` impls to `embassy-sync`, particularly on `OnceLock`
All tests green
Diffstat (limited to 'embassy-sync/src')
-rw-r--r--embassy-sync/src/blocking_mutex/mod.rs1
-rw-r--r--embassy-sync/src/blocking_mutex/raw.rs2
-rw-r--r--embassy-sync/src/channel.rs7
-rw-r--r--embassy-sync/src/lazy_lock.rs2
-rw-r--r--embassy-sync/src/mutex.rs1
-rw-r--r--embassy-sync/src/once_lock.rs10
-rw-r--r--embassy-sync/src/pipe.rs8
-rw-r--r--embassy-sync/src/pubsub/mod.rs2
-rw-r--r--embassy-sync/src/pubsub/publisher.rs6
-rw-r--r--embassy-sync/src/pubsub/subscriber.rs3
-rw-r--r--embassy-sync/src/ring_buffer.rs1
-rw-r--r--embassy-sync/src/rwlock.rs1
-rw-r--r--embassy-sync/src/semaphore.rs6
-rw-r--r--embassy-sync/src/signal.rs1
-rw-r--r--embassy-sync/src/waitqueue/atomic_waker_turbo.rs1
-rw-r--r--embassy-sync/src/waitqueue/multi_waker.rs1
-rw-r--r--embassy-sync/src/watch.rs6
-rw-r--r--embassy-sync/src/zerocopy_channel.rs5
18 files changed, 64 insertions, 0 deletions
diff --git a/embassy-sync/src/blocking_mutex/mod.rs b/embassy-sync/src/blocking_mutex/mod.rs
index a41bc3569..11809c763 100644
--- a/embassy-sync/src/blocking_mutex/mod.rs
+++ b/embassy-sync/src/blocking_mutex/mod.rs
@@ -22,6 +22,7 @@ use self::raw::RawMutex;
22/// 22///
23/// In all cases, the blocking mutex is intended to be short lived and not held across await points. 23/// In all cases, the blocking mutex is intended to be short lived and not held across await points.
24/// Use the async [`Mutex`](crate::mutex::Mutex) if you need a lock that is held across await points. 24/// Use the async [`Mutex`](crate::mutex::Mutex) if you need a lock that is held across await points.
25#[derive(Debug)]
25pub struct Mutex<R, T: ?Sized> { 26pub struct Mutex<R, T: ?Sized> {
26 // NOTE: `raw` must be FIRST, so when using ThreadModeMutex the "can't drop in non-thread-mode" gets 27 // NOTE: `raw` must be FIRST, so when using ThreadModeMutex the "can't drop in non-thread-mode" gets
27 // to run BEFORE dropping `data`. 28 // to run BEFORE dropping `data`.
diff --git a/embassy-sync/src/blocking_mutex/raw.rs b/embassy-sync/src/blocking_mutex/raw.rs
index a8afcad34..50f965e00 100644
--- a/embassy-sync/src/blocking_mutex/raw.rs
+++ b/embassy-sync/src/blocking_mutex/raw.rs
@@ -37,6 +37,7 @@ pub unsafe trait RawMutex {
37/// # Safety 37/// # Safety
38/// 38///
39/// This mutex is safe to share between different executors and interrupts. 39/// This mutex is safe to share between different executors and interrupts.
40#[derive(Debug)]
40pub struct CriticalSectionRawMutex { 41pub struct CriticalSectionRawMutex {
41 _phantom: PhantomData<()>, 42 _phantom: PhantomData<()>,
42} 43}
@@ -65,6 +66,7 @@ unsafe impl RawMutex for CriticalSectionRawMutex {
65/// # Safety 66/// # Safety
66/// 67///
67/// **This Mutex is only safe within a single executor.** 68/// **This Mutex is only safe within a single executor.**
69#[derive(Debug)]
68pub struct NoopRawMutex { 70pub struct NoopRawMutex {
69 _phantom: PhantomData<*mut ()>, 71 _phantom: PhantomData<*mut ()>,
70} 72}
diff --git a/embassy-sync/src/channel.rs b/embassy-sync/src/channel.rs
index 8e9fcc234..de437cc52 100644
--- a/embassy-sync/src/channel.rs
+++ b/embassy-sync/src/channel.rs
@@ -55,6 +55,7 @@ use crate::blocking_mutex::Mutex;
55use crate::waitqueue::WakerRegistration; 55use crate::waitqueue::WakerRegistration;
56 56
57/// Send-only access to a [`Channel`]. 57/// Send-only access to a [`Channel`].
58#[derive(Debug)]
58pub struct Sender<'ch, M, T, const N: usize> 59pub struct Sender<'ch, M, T, const N: usize>
59where 60where
60 M: RawMutex, 61 M: RawMutex,
@@ -241,6 +242,7 @@ impl<'ch, T> SendDynamicSender<'ch, T> {
241} 242}
242 243
243/// Receive-only access to a [`Channel`]. 244/// Receive-only access to a [`Channel`].
245#[derive(Debug)]
244pub struct Receiver<'ch, M, T, const N: usize> 246pub struct Receiver<'ch, M, T, const N: usize>
245where 247where
246 M: RawMutex, 248 M: RawMutex,
@@ -486,6 +488,7 @@ where
486 488
487/// Future returned by [`Channel::receive`] and [`Receiver::receive`]. 489/// Future returned by [`Channel::receive`] and [`Receiver::receive`].
488#[must_use = "futures do nothing unless you `.await` or poll them"] 490#[must_use = "futures do nothing unless you `.await` or poll them"]
491#[derive(Debug)]
489pub struct ReceiveFuture<'ch, M, T, const N: usize> 492pub struct ReceiveFuture<'ch, M, T, const N: usize>
490where 493where
491 M: RawMutex, 494 M: RawMutex,
@@ -506,6 +509,7 @@ where
506 509
507/// Future returned by [`Channel::ready_to_receive`] and [`Receiver::ready_to_receive`]. 510/// Future returned by [`Channel::ready_to_receive`] and [`Receiver::ready_to_receive`].
508#[must_use = "futures do nothing unless you `.await` or poll them"] 511#[must_use = "futures do nothing unless you `.await` or poll them"]
512#[derive(Debug)]
509pub struct ReceiveReadyFuture<'ch, M, T, const N: usize> 513pub struct ReceiveReadyFuture<'ch, M, T, const N: usize>
510where 514where
511 M: RawMutex, 515 M: RawMutex,
@@ -549,6 +553,7 @@ impl<'ch, M: RawMutex, T, const N: usize> From<ReceiveFuture<'ch, M, T, N>> for
549 553
550/// Future returned by [`Channel::send`] and [`Sender::send`]. 554/// Future returned by [`Channel::send`] and [`Sender::send`].
551#[must_use = "futures do nothing unless you `.await` or poll them"] 555#[must_use = "futures do nothing unless you `.await` or poll them"]
556#[derive(Debug)]
552pub struct SendFuture<'ch, M, T, const N: usize> 557pub struct SendFuture<'ch, M, T, const N: usize>
553where 558where
554 M: RawMutex, 559 M: RawMutex,
@@ -646,6 +651,7 @@ pub enum TrySendError<T> {
646 Full(T), 651 Full(T),
647} 652}
648 653
654#[derive(Debug)]
649struct ChannelState<T, const N: usize> { 655struct ChannelState<T, const N: usize> {
650 queue: Deque<T, N>, 656 queue: Deque<T, N>,
651 receiver_waker: WakerRegistration, 657 receiver_waker: WakerRegistration,
@@ -785,6 +791,7 @@ impl<T, const N: usize> ChannelState<T, N> {
785/// received from the channel. 791/// received from the channel.
786/// 792///
787/// All data sent will become available in the same order as it was sent. 793/// All data sent will become available in the same order as it was sent.
794#[derive(Debug)]
788pub struct Channel<M, T, const N: usize> 795pub struct Channel<M, T, const N: usize>
789where 796where
790 M: RawMutex, 797 M: RawMutex,
diff --git a/embassy-sync/src/lazy_lock.rs b/embassy-sync/src/lazy_lock.rs
index a919f0037..945560a80 100644
--- a/embassy-sync/src/lazy_lock.rs
+++ b/embassy-sync/src/lazy_lock.rs
@@ -21,6 +21,7 @@ use core::sync::atomic::{AtomicBool, Ordering};
21/// let reference = VALUE.get(); 21/// let reference = VALUE.get();
22/// assert_eq!(reference, &20); 22/// assert_eq!(reference, &20);
23/// ``` 23/// ```
24#[derive(Debug)]
24pub struct LazyLock<T, F = fn() -> T> { 25pub struct LazyLock<T, F = fn() -> T> {
25 init: AtomicBool, 26 init: AtomicBool,
26 data: UnsafeCell<Data<T, F>>, 27 data: UnsafeCell<Data<T, F>>,
@@ -144,6 +145,7 @@ mod tests {
144 } 145 }
145 146
146 static DROP_CHECKER: AtomicU32 = AtomicU32::new(0); 147 static DROP_CHECKER: AtomicU32 = AtomicU32::new(0);
148 #[derive(Debug)]
147 struct DropCheck; 149 struct DropCheck;
148 150
149 impl Drop for DropCheck { 151 impl Drop for DropCheck {
diff --git a/embassy-sync/src/mutex.rs b/embassy-sync/src/mutex.rs
index 8496f34bf..4ce6dd987 100644
--- a/embassy-sync/src/mutex.rs
+++ b/embassy-sync/src/mutex.rs
@@ -16,6 +16,7 @@ use crate::waitqueue::WakerRegistration;
16#[cfg_attr(feature = "defmt", derive(defmt::Format))] 16#[cfg_attr(feature = "defmt", derive(defmt::Format))]
17pub struct TryLockError; 17pub struct TryLockError;
18 18
19#[derive(Debug)]
19struct State { 20struct State {
20 locked: bool, 21 locked: bool,
21 waker: WakerRegistration, 22 waker: WakerRegistration,
diff --git a/embassy-sync/src/once_lock.rs b/embassy-sync/src/once_lock.rs
index 1e848685a..73edfea9a 100644
--- a/embassy-sync/src/once_lock.rs
+++ b/embassy-sync/src/once_lock.rs
@@ -1,6 +1,7 @@
1//! Synchronization primitive for initializing a value once, allowing others to await a reference to the value. 1//! Synchronization primitive for initializing a value once, allowing others to await a reference to the value.
2 2
3use core::cell::Cell; 3use core::cell::Cell;
4use core::fmt::{Debug, Formatter};
4use core::future::{poll_fn, Future}; 5use core::future::{poll_fn, Future};
5use core::mem::MaybeUninit; 6use core::mem::MaybeUninit;
6use core::sync::atomic::{AtomicBool, Ordering}; 7use core::sync::atomic::{AtomicBool, Ordering};
@@ -42,6 +43,15 @@ pub struct OnceLock<T> {
42 data: Cell<MaybeUninit<T>>, 43 data: Cell<MaybeUninit<T>>,
43} 44}
44 45
46impl<T> Debug for OnceLock<T> {
47 fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
48 f.debug_struct("OnceLock")
49 .field("init", &self.init)
50 .field("data", &"Cell<MaybeUninit<{unprintable}>>")
51 .finish()
52 }
53}
54
45unsafe impl<T> Sync for OnceLock<T> where T: Sync {} 55unsafe impl<T> Sync for OnceLock<T> where T: Sync {}
46 56
47impl<T> OnceLock<T> { 57impl<T> OnceLock<T> {
diff --git a/embassy-sync/src/pipe.rs b/embassy-sync/src/pipe.rs
index df3b28b45..6d624979a 100644
--- a/embassy-sync/src/pipe.rs
+++ b/embassy-sync/src/pipe.rs
@@ -13,6 +13,7 @@ use crate::ring_buffer::RingBuffer;
13use crate::waitqueue::WakerRegistration; 13use crate::waitqueue::WakerRegistration;
14 14
15/// Write-only access to a [`Pipe`]. 15/// Write-only access to a [`Pipe`].
16#[derive(Debug)]
16pub struct Writer<'p, M, const N: usize> 17pub struct Writer<'p, M, const N: usize>
17where 18where
18 M: RawMutex, 19 M: RawMutex,
@@ -52,6 +53,7 @@ where
52 53
53/// Future returned by [`Pipe::write`] and [`Writer::write`]. 54/// Future returned by [`Pipe::write`] and [`Writer::write`].
54#[must_use = "futures do nothing unless you `.await` or poll them"] 55#[must_use = "futures do nothing unless you `.await` or poll them"]
56#[derive(Debug)]
55pub struct WriteFuture<'p, M, const N: usize> 57pub struct WriteFuture<'p, M, const N: usize>
56where 58where
57 M: RawMutex, 59 M: RawMutex,
@@ -77,6 +79,7 @@ where
77impl<'p, M, const N: usize> Unpin for WriteFuture<'p, M, N> where M: RawMutex {} 79impl<'p, M, const N: usize> Unpin for WriteFuture<'p, M, N> where M: RawMutex {}
78 80
79/// Read-only access to a [`Pipe`]. 81/// Read-only access to a [`Pipe`].
82#[derive(Debug)]
80pub struct Reader<'p, M, const N: usize> 83pub struct Reader<'p, M, const N: usize>
81where 84where
82 M: RawMutex, 85 M: RawMutex,
@@ -128,6 +131,7 @@ where
128 131
129/// Future returned by [`Pipe::read`] and [`Reader::read`]. 132/// Future returned by [`Pipe::read`] and [`Reader::read`].
130#[must_use = "futures do nothing unless you `.await` or poll them"] 133#[must_use = "futures do nothing unless you `.await` or poll them"]
134#[derive(Debug)]
131pub struct ReadFuture<'p, M, const N: usize> 135pub struct ReadFuture<'p, M, const N: usize>
132where 136where
133 M: RawMutex, 137 M: RawMutex,
@@ -154,6 +158,7 @@ impl<'p, M, const N: usize> Unpin for ReadFuture<'p, M, N> where M: RawMutex {}
154 158
155/// Future returned by [`Reader::fill_buf`]. 159/// Future returned by [`Reader::fill_buf`].
156#[must_use = "futures do nothing unless you `.await` or poll them"] 160#[must_use = "futures do nothing unless you `.await` or poll them"]
161#[derive(Debug)]
157pub struct FillBufFuture<'p, M, const N: usize> 162pub struct FillBufFuture<'p, M, const N: usize>
158where 163where
159 M: RawMutex, 164 M: RawMutex,
@@ -199,6 +204,7 @@ pub enum TryWriteError {
199 Full, 204 Full,
200} 205}
201 206
207#[derive(Debug)]
202struct PipeState<const N: usize> { 208struct PipeState<const N: usize> {
203 buffer: RingBuffer<N>, 209 buffer: RingBuffer<N>,
204 read_waker: WakerRegistration, 210 read_waker: WakerRegistration,
@@ -206,6 +212,7 @@ struct PipeState<const N: usize> {
206} 212}
207 213
208#[repr(transparent)] 214#[repr(transparent)]
215#[derive(Debug)]
209struct Buffer<const N: usize>(UnsafeCell<[u8; N]>); 216struct Buffer<const N: usize>(UnsafeCell<[u8; N]>);
210 217
211impl<const N: usize> Buffer<N> { 218impl<const N: usize> Buffer<N> {
@@ -230,6 +237,7 @@ unsafe impl<const N: usize> Sync for Buffer<N> {}
230/// buffer is full, attempts to `write` new bytes will wait until buffer space is freed up. 237/// buffer is full, attempts to `write` new bytes will wait until buffer space is freed up.
231/// 238///
232/// All data written will become available in the same order as it was written. 239/// All data written will become available in the same order as it was written.
240#[derive(Debug)]
233pub struct Pipe<M, const N: usize> 241pub struct Pipe<M, const N: usize>
234where 242where
235 M: RawMutex, 243 M: RawMutex,
diff --git a/embassy-sync/src/pubsub/mod.rs b/embassy-sync/src/pubsub/mod.rs
index 9206b9383..ad9402f5a 100644
--- a/embassy-sync/src/pubsub/mod.rs
+++ b/embassy-sync/src/pubsub/mod.rs
@@ -71,6 +71,7 @@ pub use subscriber::{DynSubscriber, Subscriber};
71/// # block_on(test); 71/// # block_on(test);
72/// ``` 72/// ```
73/// 73///
74#[derive(Debug)]
74pub struct PubSubChannel<M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize> { 75pub struct PubSubChannel<M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize> {
75 inner: Mutex<M, RefCell<PubSubState<T, CAP, SUBS, PUBS>>>, 76 inner: Mutex<M, RefCell<PubSubState<T, CAP, SUBS, PUBS>>>,
76} 77}
@@ -297,6 +298,7 @@ impl<M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usi
297} 298}
298 299
299/// Internal state for the PubSub channel 300/// Internal state for the PubSub channel
301#[derive(Debug)]
300struct PubSubState<T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize> { 302struct PubSubState<T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize> {
301 /// The queue contains the last messages that have been published and a countdown of how many subscribers are yet to read it 303 /// The queue contains the last messages that have been published and a countdown of how many subscribers are yet to read it
302 queue: Deque<(T, usize), CAP>, 304 queue: Deque<(T, usize), CAP>,
diff --git a/embassy-sync/src/pubsub/publisher.rs b/embassy-sync/src/pubsub/publisher.rs
index 52a52f926..2a67a0002 100644
--- a/embassy-sync/src/pubsub/publisher.rs
+++ b/embassy-sync/src/pubsub/publisher.rs
@@ -10,6 +10,7 @@ use super::{PubSubBehavior, PubSubChannel};
10use crate::blocking_mutex::raw::RawMutex; 10use crate::blocking_mutex::raw::RawMutex;
11 11
12/// A publisher to a channel 12/// A publisher to a channel
13#[derive(Debug)]
13pub struct Pub<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> { 14pub struct Pub<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> {
14 /// The channel we are a publisher for 15 /// The channel we are a publisher for
15 channel: &'a PSB, 16 channel: &'a PSB,
@@ -106,6 +107,7 @@ impl<'a, T: Clone> DerefMut for DynPublisher<'a, T> {
106} 107}
107 108
108/// A publisher that holds a generic reference to the channel 109/// A publisher that holds a generic reference to the channel
110#[derive(Debug)]
109pub struct Publisher<'a, M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize>( 111pub struct Publisher<'a, M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize>(
110 pub(super) Pub<'a, PubSubChannel<M, T, CAP, SUBS, PUBS>, T>, 112 pub(super) Pub<'a, PubSubChannel<M, T, CAP, SUBS, PUBS>, T>,
111); 113);
@@ -130,6 +132,7 @@ impl<'a, M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS:
130 132
131/// A publisher that can only use the `publish_immediate` function, but it doesn't have to be registered with the channel. 133/// A publisher that can only use the `publish_immediate` function, but it doesn't have to be registered with the channel.
132/// (So an infinite amount is possible) 134/// (So an infinite amount is possible)
135#[derive(Debug)]
133pub struct ImmediatePub<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> { 136pub struct ImmediatePub<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> {
134 /// The channel we are a publisher for 137 /// The channel we are a publisher for
135 channel: &'a PSB, 138 channel: &'a PSB,
@@ -205,6 +208,7 @@ impl<'a, T: Clone> DerefMut for DynImmediatePublisher<'a, T> {
205} 208}
206 209
207/// An immediate publisher that holds a generic reference to the channel 210/// An immediate publisher that holds a generic reference to the channel
211#[derive(Debug)]
208pub struct ImmediatePublisher<'a, M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize>( 212pub struct ImmediatePublisher<'a, M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize>(
209 pub(super) ImmediatePub<'a, PubSubChannel<M, T, CAP, SUBS, PUBS>, T>, 213 pub(super) ImmediatePub<'a, PubSubChannel<M, T, CAP, SUBS, PUBS>, T>,
210); 214);
@@ -229,6 +233,7 @@ impl<'a, M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS:
229 233
230#[must_use = "Sinks do nothing unless polled"] 234#[must_use = "Sinks do nothing unless polled"]
231/// [`futures_sink::Sink`] adapter for [`Pub`]. 235/// [`futures_sink::Sink`] adapter for [`Pub`].
236#[derive(Debug)]
232pub struct PubSink<'a, 'p, PSB, T> 237pub struct PubSink<'a, 'p, PSB, T>
233where 238where
234 T: Clone, 239 T: Clone,
@@ -290,6 +295,7 @@ where
290 295
291/// Future for the publisher wait action 296/// Future for the publisher wait action
292#[must_use = "futures do nothing unless you `.await` or poll them"] 297#[must_use = "futures do nothing unless you `.await` or poll them"]
298#[derive(Debug)]
293pub struct PublisherWaitFuture<'s, 'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> { 299pub struct PublisherWaitFuture<'s, 'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> {
294 /// The message we need to publish 300 /// The message we need to publish
295 message: Option<T>, 301 message: Option<T>,
diff --git a/embassy-sync/src/pubsub/subscriber.rs b/embassy-sync/src/pubsub/subscriber.rs
index 649382cf1..356de23f6 100644
--- a/embassy-sync/src/pubsub/subscriber.rs
+++ b/embassy-sync/src/pubsub/subscriber.rs
@@ -10,6 +10,7 @@ use super::{PubSubBehavior, PubSubChannel, WaitResult};
10use crate::blocking_mutex::raw::RawMutex; 10use crate::blocking_mutex::raw::RawMutex;
11 11
12/// A subscriber to a channel 12/// A subscriber to a channel
13#[derive(Debug)]
13pub struct Sub<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> { 14pub struct Sub<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> {
14 /// The message id of the next message we are yet to receive 15 /// The message id of the next message we are yet to receive
15 next_message_id: u64, 16 next_message_id: u64,
@@ -151,6 +152,7 @@ impl<'a, T: Clone> DerefMut for DynSubscriber<'a, T> {
151} 152}
152 153
153/// A subscriber that holds a generic reference to the channel 154/// A subscriber that holds a generic reference to the channel
155#[derive(Debug)]
154pub struct Subscriber<'a, M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize>( 156pub struct Subscriber<'a, M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usize>(
155 pub(super) Sub<'a, PubSubChannel<M, T, CAP, SUBS, PUBS>, T>, 157 pub(super) Sub<'a, PubSubChannel<M, T, CAP, SUBS, PUBS>, T>,
156); 158);
@@ -175,6 +177,7 @@ impl<'a, M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS:
175 177
176/// Future for the subscriber wait action 178/// Future for the subscriber wait action
177#[must_use = "futures do nothing unless you `.await` or poll them"] 179#[must_use = "futures do nothing unless you `.await` or poll them"]
180#[derive(Debug)]
178pub struct SubscriberWaitFuture<'s, 'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> { 181pub struct SubscriberWaitFuture<'s, 'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> {
179 subscriber: &'s mut Sub<'a, PSB, T>, 182 subscriber: &'s mut Sub<'a, PSB, T>,
180} 183}
diff --git a/embassy-sync/src/ring_buffer.rs b/embassy-sync/src/ring_buffer.rs
index 81e60c42b..f03b7dd8f 100644
--- a/embassy-sync/src/ring_buffer.rs
+++ b/embassy-sync/src/ring_buffer.rs
@@ -1,5 +1,6 @@
1use core::ops::Range; 1use core::ops::Range;
2 2
3#[derive(Debug)]
3pub struct RingBuffer<const N: usize> { 4pub struct RingBuffer<const N: usize> {
4 start: usize, 5 start: usize,
5 end: usize, 6 end: usize,
diff --git a/embassy-sync/src/rwlock.rs b/embassy-sync/src/rwlock.rs
index deeadd167..0d784a7dc 100644
--- a/embassy-sync/src/rwlock.rs
+++ b/embassy-sync/src/rwlock.rs
@@ -16,6 +16,7 @@ use crate::waitqueue::WakerRegistration;
16#[cfg_attr(feature = "defmt", derive(defmt::Format))] 16#[cfg_attr(feature = "defmt", derive(defmt::Format))]
17pub struct TryLockError; 17pub struct TryLockError;
18 18
19#[derive(Debug)]
19struct State { 20struct State {
20 readers: usize, 21 readers: usize,
21 writer: bool, 22 writer: bool,
diff --git a/embassy-sync/src/semaphore.rs b/embassy-sync/src/semaphore.rs
index d30eee30b..4e82b0fcd 100644
--- a/embassy-sync/src/semaphore.rs
+++ b/embassy-sync/src/semaphore.rs
@@ -46,6 +46,7 @@ pub trait Semaphore: Sized {
46/// A representation of a number of acquired permits. 46/// A representation of a number of acquired permits.
47/// 47///
48/// The acquired permits will be released back to the [`Semaphore`] when this is dropped. 48/// The acquired permits will be released back to the [`Semaphore`] when this is dropped.
49#[derive(Debug)]
49pub struct SemaphoreReleaser<'a, S: Semaphore> { 50pub struct SemaphoreReleaser<'a, S: Semaphore> {
50 semaphore: &'a S, 51 semaphore: &'a S,
51 permits: usize, 52 permits: usize,
@@ -181,6 +182,7 @@ impl<M: RawMutex> Semaphore for GreedySemaphore<M> {
181 } 182 }
182} 183}
183 184
185#[derive(Debug)]
184struct SemaphoreState { 186struct SemaphoreState {
185 permits: usize, 187 permits: usize,
186 waker: WakerRegistration, 188 waker: WakerRegistration,
@@ -221,6 +223,7 @@ impl SemaphoreState {
221/// 223///
222/// Up to `N` tasks may attempt to acquire permits concurrently. If additional 224/// Up to `N` tasks may attempt to acquire permits concurrently. If additional
223/// tasks attempt to acquire a permit, a [`WaitQueueFull`] error will be returned. 225/// tasks attempt to acquire a permit, a [`WaitQueueFull`] error will be returned.
226#[derive(Debug)]
224pub struct FairSemaphore<M, const N: usize> 227pub struct FairSemaphore<M, const N: usize>
225where 228where
226 M: RawMutex, 229 M: RawMutex,
@@ -341,6 +344,7 @@ impl<M: RawMutex, const N: usize> Semaphore for FairSemaphore<M, N> {
341 } 344 }
342} 345}
343 346
347#[derive(Debug)]
344struct FairAcquire<'a, M: RawMutex, const N: usize> { 348struct FairAcquire<'a, M: RawMutex, const N: usize> {
345 sema: &'a FairSemaphore<M, N>, 349 sema: &'a FairSemaphore<M, N>,
346 permits: usize, 350 permits: usize,
@@ -364,6 +368,7 @@ impl<'a, M: RawMutex, const N: usize> core::future::Future for FairAcquire<'a, M
364 } 368 }
365} 369}
366 370
371#[derive(Debug)]
367struct FairAcquireAll<'a, M: RawMutex, const N: usize> { 372struct FairAcquireAll<'a, M: RawMutex, const N: usize> {
368 sema: &'a FairSemaphore<M, N>, 373 sema: &'a FairSemaphore<M, N>,
369 min: usize, 374 min: usize,
@@ -387,6 +392,7 @@ impl<'a, M: RawMutex, const N: usize> core::future::Future for FairAcquireAll<'a
387 } 392 }
388} 393}
389 394
395#[derive(Debug)]
390struct FairSemaphoreState<const N: usize> { 396struct FairSemaphoreState<const N: usize> {
391 permits: usize, 397 permits: usize,
392 next_ticket: usize, 398 next_ticket: usize,
diff --git a/embassy-sync/src/signal.rs b/embassy-sync/src/signal.rs
index e7095401e..d96e36245 100644
--- a/embassy-sync/src/signal.rs
+++ b/embassy-sync/src/signal.rs
@@ -39,6 +39,7 @@ where
39 state: Mutex<M, Cell<State<T>>>, 39 state: Mutex<M, Cell<State<T>>>,
40} 40}
41 41
42#[derive(Debug)]
42enum State<T> { 43enum State<T> {
43 None, 44 None,
44 Waiting(Waker), 45 Waiting(Waker),
diff --git a/embassy-sync/src/waitqueue/atomic_waker_turbo.rs b/embassy-sync/src/waitqueue/atomic_waker_turbo.rs
index c06b83056..a45adeab8 100644
--- a/embassy-sync/src/waitqueue/atomic_waker_turbo.rs
+++ b/embassy-sync/src/waitqueue/atomic_waker_turbo.rs
@@ -7,6 +7,7 @@ use core::task::Waker;
7/// If a waker is registered, registering another waker will replace the previous one without waking it. 7/// If a waker is registered, registering another waker will replace the previous one without waking it.
8/// The intended use case is to wake tasks from interrupts. Therefore, it is generally not expected, 8/// The intended use case is to wake tasks from interrupts. Therefore, it is generally not expected,
9/// that multiple tasks register try to register a waker simultaneously. 9/// that multiple tasks register try to register a waker simultaneously.
10#[derive(Debug)]
10pub struct AtomicWaker { 11pub struct AtomicWaker {
11 waker: AtomicPtr<()>, 12 waker: AtomicPtr<()>,
12} 13}
diff --git a/embassy-sync/src/waitqueue/multi_waker.rs b/embassy-sync/src/waitqueue/multi_waker.rs
index 1c05f8eaf..56c0cd1b2 100644
--- a/embassy-sync/src/waitqueue/multi_waker.rs
+++ b/embassy-sync/src/waitqueue/multi_waker.rs
@@ -5,6 +5,7 @@ use heapless::Vec;
5/// Utility struct to register and wake multiple wakers. 5/// Utility struct to register and wake multiple wakers.
6/// Queue of wakers with a maximum length of `N`. 6/// Queue of wakers with a maximum length of `N`.
7/// Intended for waking multiple tasks. 7/// Intended for waking multiple tasks.
8#[derive(Debug)]
8pub struct MultiWakerRegistration<const N: usize> { 9pub struct MultiWakerRegistration<const N: usize> {
9 wakers: Vec<Waker, N>, 10 wakers: Vec<Waker, N>,
10} 11}
diff --git a/embassy-sync/src/watch.rs b/embassy-sync/src/watch.rs
index 08d6a833d..332ab5405 100644
--- a/embassy-sync/src/watch.rs
+++ b/embassy-sync/src/watch.rs
@@ -65,10 +65,12 @@ use crate::waitqueue::MultiWakerRegistration;
65/// }; 65/// };
66/// block_on(f); 66/// block_on(f);
67/// ``` 67/// ```
68#[derive(Debug)]
68pub struct Watch<M: RawMutex, T: Clone, const N: usize> { 69pub struct Watch<M: RawMutex, T: Clone, const N: usize> {
69 mutex: Mutex<M, RefCell<WatchState<T, N>>>, 70 mutex: Mutex<M, RefCell<WatchState<T, N>>>,
70} 71}
71 72
73#[derive(Debug)]
72struct WatchState<T: Clone, const N: usize> { 74struct WatchState<T: Clone, const N: usize> {
73 data: Option<T>, 75 data: Option<T>,
74 current_id: u64, 76 current_id: u64,
@@ -392,6 +394,7 @@ impl<M: RawMutex, T: Clone, const N: usize> Watch<M, T, N> {
392} 394}
393 395
394/// A receiver can `.await` a change in the `Watch` value. 396/// A receiver can `.await` a change in the `Watch` value.
397#[derive(Debug)]
395pub struct Snd<'a, T: Clone, W: WatchBehavior<T> + ?Sized> { 398pub struct Snd<'a, T: Clone, W: WatchBehavior<T> + ?Sized> {
396 watch: &'a W, 399 watch: &'a W,
397 _phantom: PhantomData<T>, 400 _phantom: PhantomData<T>,
@@ -467,6 +470,7 @@ impl<'a, T: Clone, W: WatchBehavior<T> + ?Sized> Snd<'a, T, W> {
467/// 470///
468/// For a simpler type definition, consider [`DynSender`] at the expense of 471/// For a simpler type definition, consider [`DynSender`] at the expense of
469/// some runtime performance due to dynamic dispatch. 472/// some runtime performance due to dynamic dispatch.
473#[derive(Debug)]
470pub struct Sender<'a, M: RawMutex, T: Clone, const N: usize>(Snd<'a, T, Watch<M, T, N>>); 474pub struct Sender<'a, M: RawMutex, T: Clone, const N: usize>(Snd<'a, T, Watch<M, T, N>>);
471 475
472impl<'a, M: RawMutex, T: Clone, const N: usize> Clone for Sender<'a, M, T, N> { 476impl<'a, M: RawMutex, T: Clone, const N: usize> Clone for Sender<'a, M, T, N> {
@@ -622,6 +626,7 @@ impl<'a, T: Clone, W: WatchBehavior<T> + ?Sized> Drop for Rcv<'a, T, W> {
622} 626}
623 627
624/// A anonymous receiver can NOT `.await` a change in the `Watch` value. 628/// A anonymous receiver can NOT `.await` a change in the `Watch` value.
629#[derive(Debug)]
625pub struct AnonRcv<'a, T: Clone, W: WatchBehavior<T> + ?Sized> { 630pub struct AnonRcv<'a, T: Clone, W: WatchBehavior<T> + ?Sized> {
626 watch: &'a W, 631 watch: &'a W,
627 at_id: u64, 632 at_id: u64,
@@ -726,6 +731,7 @@ impl<'a, T: Clone> DerefMut for DynReceiver<'a, T> {
726} 731}
727 732
728/// A receiver of a `Watch` channel that cannot `.await` values. 733/// A receiver of a `Watch` channel that cannot `.await` values.
734#[derive(Debug)]
729pub struct AnonReceiver<'a, M: RawMutex, T: Clone, const N: usize>(AnonRcv<'a, T, Watch<M, T, N>>); 735pub struct AnonReceiver<'a, M: RawMutex, T: Clone, const N: usize>(AnonRcv<'a, T, Watch<M, T, N>>);
730 736
731impl<'a, M: RawMutex, T: Clone, const N: usize> AnonReceiver<'a, M, T, N> { 737impl<'a, M: RawMutex, T: Clone, const N: usize> AnonReceiver<'a, M, T, N> {
diff --git a/embassy-sync/src/zerocopy_channel.rs b/embassy-sync/src/zerocopy_channel.rs
index e3e5b2538..b3f7dbe8c 100644
--- a/embassy-sync/src/zerocopy_channel.rs
+++ b/embassy-sync/src/zerocopy_channel.rs
@@ -34,6 +34,7 @@ use crate::waitqueue::WakerRegistration;
34/// 34///
35/// The channel requires a buffer of recyclable elements. Writing to the channel is done through 35/// The channel requires a buffer of recyclable elements. Writing to the channel is done through
36/// an `&mut T`. 36/// an `&mut T`.
37#[derive(Debug)]
37pub struct Channel<'a, M: RawMutex, T> { 38pub struct Channel<'a, M: RawMutex, T> {
38 buf: BufferPtr<T>, 39 buf: BufferPtr<T>,
39 phantom: PhantomData<&'a mut T>, 40 phantom: PhantomData<&'a mut T>,
@@ -95,6 +96,7 @@ impl<'a, M: RawMutex, T> Channel<'a, M, T> {
95} 96}
96 97
97#[repr(transparent)] 98#[repr(transparent)]
99#[derive(Debug)]
98struct BufferPtr<T>(*mut T); 100struct BufferPtr<T>(*mut T);
99 101
100impl<T> BufferPtr<T> { 102impl<T> BufferPtr<T> {
@@ -107,6 +109,7 @@ unsafe impl<T> Send for BufferPtr<T> {}
107unsafe impl<T> Sync for BufferPtr<T> {} 109unsafe impl<T> Sync for BufferPtr<T> {}
108 110
109/// Send-only access to a [`Channel`]. 111/// Send-only access to a [`Channel`].
112#[derive(Debug)]
110pub struct Sender<'a, M: RawMutex, T> { 113pub struct Sender<'a, M: RawMutex, T> {
111 channel: &'a Channel<'a, M, T>, 114 channel: &'a Channel<'a, M, T>,
112} 115}
@@ -190,6 +193,7 @@ impl<'a, M: RawMutex, T> Sender<'a, M, T> {
190} 193}
191 194
192/// Receive-only access to a [`Channel`]. 195/// Receive-only access to a [`Channel`].
196#[derive(Debug)]
193pub struct Receiver<'a, M: RawMutex, T> { 197pub struct Receiver<'a, M: RawMutex, T> {
194 channel: &'a Channel<'a, M, T>, 198 channel: &'a Channel<'a, M, T>,
195} 199}
@@ -272,6 +276,7 @@ impl<'a, M: RawMutex, T> Receiver<'a, M, T> {
272 } 276 }
273} 277}
274 278
279#[derive(Debug)]
275struct State { 280struct State {
276 /// Maximum number of elements the channel can hold. 281 /// Maximum number of elements the channel can hold.
277 capacity: usize, 282 capacity: usize,