diff options
Diffstat (limited to 'embassy-sync/src')
| -rw-r--r-- | embassy-sync/src/channel.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/embassy-sync/src/channel.rs b/embassy-sync/src/channel.rs index 9a7d2fa2f..4d1fa9e39 100644 --- a/embassy-sync/src/channel.rs +++ b/embassy-sync/src/channel.rs | |||
| @@ -317,6 +317,17 @@ where | |||
| 317 | } | 317 | } |
| 318 | } | 318 | } |
| 319 | 319 | ||
| 320 | impl<'ch, M, T, const N: usize> futures_util::Stream for Receiver<'ch, M, T, N> | ||
| 321 | where | ||
| 322 | M: RawMutex, | ||
| 323 | { | ||
| 324 | type Item = T; | ||
| 325 | |||
| 326 | fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { | ||
| 327 | self.channel.poll_receive(cx).map(Some) | ||
| 328 | } | ||
| 329 | } | ||
| 330 | |||
| 320 | /// Future returned by [`Channel::receive`] and [`Receiver::receive`]. | 331 | /// Future returned by [`Channel::receive`] and [`Receiver::receive`]. |
| 321 | #[must_use = "futures do nothing unless you `.await` or poll them"] | 332 | #[must_use = "futures do nothing unless you `.await` or poll them"] |
| 322 | pub struct ReceiveFuture<'ch, M, T, const N: usize> | 333 | pub struct ReceiveFuture<'ch, M, T, const N: usize> |
| @@ -771,6 +782,17 @@ where | |||
| 771 | } | 782 | } |
| 772 | } | 783 | } |
| 773 | 784 | ||
| 785 | impl<M, T, const N: usize> futures_util::Stream for Channel<M, T, N> | ||
| 786 | where | ||
| 787 | M: RawMutex, | ||
| 788 | { | ||
| 789 | type Item = T; | ||
| 790 | |||
| 791 | fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { | ||
| 792 | self.poll_receive(cx).map(Some) | ||
| 793 | } | ||
| 794 | } | ||
| 795 | |||
| 774 | #[cfg(test)] | 796 | #[cfg(test)] |
| 775 | mod tests { | 797 | mod tests { |
| 776 | use core::time::Duration; | 798 | use core::time::Duration; |
