diff options
| author | Ulf Lilleengen <[email protected]> | 2024-03-12 15:50:02 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-03-12 15:50:02 +0000 |
| commit | 7c82583d56e7118a408fd317a1a3466eab678034 (patch) | |
| tree | 15f2d0ed5142603c8812641511d8c5c12b8ec1a3 /embassy-sync/src | |
| parent | 1ef02e538497d1876ec26f8acf0763d6c3263382 (diff) | |
| parent | c0d91600ea7b6847e2295a0fee819291c951132f (diff) | |
Merge pull request #2689 from embassy-rs/dyn-channel-futures
Add conversion into dyn variants for channel futures
Diffstat (limited to 'embassy-sync/src')
| -rw-r--r-- | embassy-sync/src/channel.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/embassy-sync/src/channel.rs b/embassy-sync/src/channel.rs index 01db0d09a..48f4dafd6 100644 --- a/embassy-sync/src/channel.rs +++ b/embassy-sync/src/channel.rs | |||
| @@ -263,6 +263,12 @@ impl<'ch, T> Future for DynamicReceiveFuture<'ch, T> { | |||
| 263 | } | 263 | } |
| 264 | } | 264 | } |
| 265 | 265 | ||
| 266 | impl<'ch, M: RawMutex, T, const N: usize> From<ReceiveFuture<'ch, M, T, N>> for DynamicReceiveFuture<'ch, T> { | ||
| 267 | fn from(value: ReceiveFuture<'ch, M, T, N>) -> Self { | ||
| 268 | Self { channel: value.channel } | ||
| 269 | } | ||
| 270 | } | ||
| 271 | |||
| 266 | /// Future returned by [`Channel::send`] and [`Sender::send`]. | 272 | /// Future returned by [`Channel::send`] and [`Sender::send`]. |
| 267 | #[must_use = "futures do nothing unless you `.await` or poll them"] | 273 | #[must_use = "futures do nothing unless you `.await` or poll them"] |
| 268 | pub struct SendFuture<'ch, M, T, const N: usize> | 274 | pub struct SendFuture<'ch, M, T, const N: usize> |
| @@ -321,6 +327,15 @@ impl<'ch, T> Future for DynamicSendFuture<'ch, T> { | |||
| 321 | 327 | ||
| 322 | impl<'ch, T> Unpin for DynamicSendFuture<'ch, T> {} | 328 | impl<'ch, T> Unpin for DynamicSendFuture<'ch, T> {} |
| 323 | 329 | ||
| 330 | impl<'ch, M: RawMutex, T, const N: usize> From<SendFuture<'ch, M, T, N>> for DynamicSendFuture<'ch, T> { | ||
| 331 | fn from(value: SendFuture<'ch, M, T, N>) -> Self { | ||
| 332 | Self { | ||
| 333 | channel: value.channel, | ||
| 334 | message: value.message, | ||
| 335 | } | ||
| 336 | } | ||
| 337 | } | ||
| 338 | |||
| 324 | pub(crate) trait DynamicChannel<T> { | 339 | pub(crate) trait DynamicChannel<T> { |
| 325 | fn try_send_with_context(&self, message: T, cx: Option<&mut Context<'_>>) -> Result<(), TrySendError<T>>; | 340 | fn try_send_with_context(&self, message: T, cx: Option<&mut Context<'_>>) -> Result<(), TrySendError<T>>; |
| 326 | 341 | ||
