diff options
| author | 1-rafael-1 <[email protected]> | 2025-09-15 20:07:18 +0200 |
|---|---|---|
| committer | 1-rafael-1 <[email protected]> | 2025-09-15 20:07:18 +0200 |
| commit | 6bb3d2c0720fa082f27d3cdb70f516058497ec87 (patch) | |
| tree | 5a1e255cff999b00800f203b91a759c720c973e5 /embassy-sync/src/pipe.rs | |
| parent | eb685574601d98c44faed9a3534d056199b46e20 (diff) | |
| parent | 92a6fd2946f2cbb15359290f68aa360953da2ff7 (diff) | |
Merge branch 'main' into rp2040-rtc-alarm
Diffstat (limited to 'embassy-sync/src/pipe.rs')
| -rw-r--r-- | embassy-sync/src/pipe.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/embassy-sync/src/pipe.rs b/embassy-sync/src/pipe.rs index 2598652d2..6d624979a 100644 --- a/embassy-sync/src/pipe.rs +++ b/embassy-sync/src/pipe.rs | |||
| @@ -13,6 +13,7 @@ use crate::ring_buffer::RingBuffer; | |||
| 13 | use crate::waitqueue::WakerRegistration; | 13 | use crate::waitqueue::WakerRegistration; |
| 14 | 14 | ||
| 15 | /// Write-only access to a [`Pipe`]. | 15 | /// Write-only access to a [`Pipe`]. |
| 16 | #[derive(Debug)] | ||
| 16 | pub struct Writer<'p, M, const N: usize> | 17 | pub struct Writer<'p, M, const N: usize> |
| 17 | where | 18 | where |
| 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)] | ||
| 55 | pub struct WriteFuture<'p, M, const N: usize> | 57 | pub struct WriteFuture<'p, M, const N: usize> |
| 56 | where | 58 | where |
| 57 | M: RawMutex, | 59 | M: RawMutex, |
| @@ -77,6 +79,7 @@ where | |||
| 77 | impl<'p, M, const N: usize> Unpin for WriteFuture<'p, M, N> where M: RawMutex {} | 79 | impl<'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)] | ||
| 80 | pub struct Reader<'p, M, const N: usize> | 83 | pub struct Reader<'p, M, const N: usize> |
| 81 | where | 84 | where |
| 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)] | ||
| 131 | pub struct ReadFuture<'p, M, const N: usize> | 135 | pub struct ReadFuture<'p, M, const N: usize> |
| 132 | where | 136 | where |
| 133 | M: RawMutex, | 137 | M: RawMutex, |
| @@ -152,8 +156,9 @@ where | |||
| 152 | 156 | ||
| 153 | impl<'p, M, const N: usize> Unpin for ReadFuture<'p, M, N> where M: RawMutex {} | 157 | impl<'p, M, const N: usize> Unpin for ReadFuture<'p, M, N> where M: RawMutex {} |
| 154 | 158 | ||
| 155 | /// Future returned by [`Pipe::fill_buf`] and [`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)] | ||
| 157 | pub struct FillBufFuture<'p, M, const N: usize> | 162 | pub struct FillBufFuture<'p, M, const N: usize> |
| 158 | where | 163 | where |
| 159 | M: RawMutex, | 164 | M: RawMutex, |
| @@ -199,6 +204,7 @@ pub enum TryWriteError { | |||
| 199 | Full, | 204 | Full, |
| 200 | } | 205 | } |
| 201 | 206 | ||
| 207 | #[derive(Debug)] | ||
| 202 | struct PipeState<const N: usize> { | 208 | struct 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)] | ||
| 209 | struct Buffer<const N: usize>(UnsafeCell<[u8; N]>); | 216 | struct Buffer<const N: usize>(UnsafeCell<[u8; N]>); |
| 210 | 217 | ||
| 211 | impl<const N: usize> Buffer<N> { | 218 | impl<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)] | ||
| 233 | pub struct Pipe<M, const N: usize> | 241 | pub struct Pipe<M, const N: usize> |
| 234 | where | 242 | where |
| 235 | M: RawMutex, | 243 | M: RawMutex, |
| @@ -587,7 +595,7 @@ where | |||
| 587 | } | 595 | } |
| 588 | } | 596 | } |
| 589 | 597 | ||
| 590 | /// Write-only access to a [`DynamicPipe`]. | 598 | /// Write-only access to the dynamic pipe. |
| 591 | pub struct DynamicWriter<'p> { | 599 | pub struct DynamicWriter<'p> { |
| 592 | pipe: &'p dyn DynamicPipe, | 600 | pipe: &'p dyn DynamicPipe, |
| 593 | } | 601 | } |
| @@ -657,7 +665,7 @@ where | |||
| 657 | } | 665 | } |
| 658 | } | 666 | } |
| 659 | 667 | ||
| 660 | /// Read-only access to a [`DynamicPipe`]. | 668 | /// Read-only access to a dynamic pipe. |
| 661 | pub struct DynamicReader<'p> { | 669 | pub struct DynamicReader<'p> { |
| 662 | pipe: &'p dyn DynamicPipe, | 670 | pipe: &'p dyn DynamicPipe, |
| 663 | } | 671 | } |
| @@ -742,7 +750,7 @@ where | |||
| 742 | } | 750 | } |
| 743 | } | 751 | } |
| 744 | 752 | ||
| 745 | /// Future returned by [`DynamicPipe::fill_buf`] and [`DynamicReader::fill_buf`]. | 753 | /// Future returned by [`DynamicReader::fill_buf`]. |
| 746 | #[must_use = "futures do nothing unless you `.await` or poll them"] | 754 | #[must_use = "futures do nothing unless you `.await` or poll them"] |
| 747 | pub struct DynamicFillBufFuture<'p> { | 755 | pub struct DynamicFillBufFuture<'p> { |
| 748 | pipe: Option<&'p dyn DynamicPipe>, | 756 | pipe: Option<&'p dyn DynamicPipe>, |
