aboutsummaryrefslogtreecommitdiff
path: root/embassy-sync/src/pipe.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-sync/src/pipe.rs')
-rw-r--r--embassy-sync/src/pipe.rs8
1 files changed, 8 insertions, 0 deletions
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,