mirror of
https://github.com/embassy-rs/embassy.git
synced 2025-09-27 12:20:37 +00:00
add stream impl
This commit is contained in:
parent
195b1a593a
commit
269dec9380
@ -317,6 +317,17 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'ch, M, T, const N: usize> futures_util::Stream for Receiver<'ch, M, T, N>
|
||||||
|
where
|
||||||
|
M: RawMutex,
|
||||||
|
{
|
||||||
|
type Item = T;
|
||||||
|
|
||||||
|
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||||
|
self.channel.poll_receive(cx).map(Some)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Future returned by [`Channel::receive`] and [`Receiver::receive`].
|
/// Future returned by [`Channel::receive`] and [`Receiver::receive`].
|
||||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||||
pub struct ReceiveFuture<'ch, M, T, const N: usize>
|
pub struct ReceiveFuture<'ch, M, T, const N: usize>
|
||||||
@ -768,6 +779,17 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<M, T, const N: usize> futures_util::Stream for Channel<M, T, N>
|
||||||
|
where
|
||||||
|
M: RawMutex,
|
||||||
|
{
|
||||||
|
type Item = T;
|
||||||
|
|
||||||
|
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||||
|
self.poll_receive(cx).map(Some)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user