diff options
Diffstat (limited to 'embassy-sync')
| -rw-r--r-- | embassy-sync/src/lib.rs | 3 | ||||
| -rw-r--r-- | embassy-sync/src/pipe.rs | 74 |
2 files changed, 20 insertions, 57 deletions
diff --git a/embassy-sync/src/lib.rs b/embassy-sync/src/lib.rs index 80bb907a3..f9435ecff 100644 --- a/embassy-sync/src/lib.rs +++ b/embassy-sync/src/lib.rs | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)] | 1 | #![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)] |
| 2 | #![cfg_attr(feature = "nightly", feature(type_alias_impl_trait))] | 2 | #![cfg_attr(feature = "nightly", feature(async_fn_in_trait, impl_trait_projections))] |
| 3 | #![cfg_attr(feature = "nightly", allow(incomplete_features))] | ||
| 3 | #![allow(clippy::new_without_default)] | 4 | #![allow(clippy::new_without_default)] |
| 4 | #![doc = include_str!("../README.md")] | 5 | #![doc = include_str!("../README.md")] |
| 5 | #![warn(missing_docs)] | 6 | #![warn(missing_docs)] |
diff --git a/embassy-sync/src/pipe.rs b/embassy-sync/src/pipe.rs index cd577f34f..905686acd 100644 --- a/embassy-sync/src/pipe.rs +++ b/embassy-sync/src/pipe.rs | |||
| @@ -352,8 +352,6 @@ where | |||
| 352 | mod io_impls { | 352 | mod io_impls { |
| 353 | use core::convert::Infallible; | 353 | use core::convert::Infallible; |
| 354 | 354 | ||
| 355 | use futures_util::FutureExt; | ||
| 356 | |||
| 357 | use super::*; | 355 | use super::*; |
| 358 | 356 | ||
| 359 | impl<M: RawMutex, const N: usize> embedded_io::Io for Pipe<M, N> { | 357 | impl<M: RawMutex, const N: usize> embedded_io::Io for Pipe<M, N> { |
| @@ -361,30 +359,18 @@ mod io_impls { | |||
| 361 | } | 359 | } |
| 362 | 360 | ||
| 363 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Read for Pipe<M, N> { | 361 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Read for Pipe<M, N> { |
| 364 | type ReadFuture<'a> = impl Future<Output = Result<usize, Self::Error>> + 'a | 362 | async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { |
| 365 | where | 363 | Ok(Pipe::read(self, buf).await) |
| 366 | Self: 'a; | ||
| 367 | |||
| 368 | fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { | ||
| 369 | Pipe::read(self, buf).map(Ok) | ||
| 370 | } | 364 | } |
| 371 | } | 365 | } |
| 372 | 366 | ||
| 373 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Write for Pipe<M, N> { | 367 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Write for Pipe<M, N> { |
| 374 | type WriteFuture<'a> = impl Future<Output = Result<usize, Self::Error>> + 'a | 368 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { |
| 375 | where | 369 | Ok(Pipe::write(self, buf).await) |
| 376 | Self: 'a; | ||
| 377 | |||
| 378 | fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { | ||
| 379 | Pipe::write(self, buf).map(Ok) | ||
| 380 | } | 370 | } |
| 381 | 371 | ||
| 382 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a | 372 | async fn flush(&mut self) -> Result<(), Self::Error> { |
| 383 | where | 373 | Ok(()) |
| 384 | Self: 'a; | ||
| 385 | |||
| 386 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | ||
| 387 | futures_util::future::ready(Ok(())) | ||
| 388 | } | 374 | } |
| 389 | } | 375 | } |
| 390 | 376 | ||
| @@ -393,30 +379,18 @@ mod io_impls { | |||
| 393 | } | 379 | } |
| 394 | 380 | ||
| 395 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Read for &Pipe<M, N> { | 381 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Read for &Pipe<M, N> { |
| 396 | type ReadFuture<'a> = impl Future<Output = Result<usize, Self::Error>> + 'a | 382 | async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { |
| 397 | where | 383 | Ok(Pipe::read(self, buf).await) |
| 398 | Self: 'a; | ||
| 399 | |||
| 400 | fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { | ||
| 401 | Pipe::read(self, buf).map(Ok) | ||
| 402 | } | 384 | } |
| 403 | } | 385 | } |
| 404 | 386 | ||
| 405 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Write for &Pipe<M, N> { | 387 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Write for &Pipe<M, N> { |
| 406 | type WriteFuture<'a> = impl Future<Output = Result<usize, Self::Error>> + 'a | 388 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { |
| 407 | where | 389 | Ok(Pipe::write(self, buf).await) |
| 408 | Self: 'a; | ||
| 409 | |||
| 410 | fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { | ||
| 411 | Pipe::write(self, buf).map(Ok) | ||
| 412 | } | 390 | } |
| 413 | 391 | ||
| 414 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a | 392 | async fn flush(&mut self) -> Result<(), Self::Error> { |
| 415 | where | 393 | Ok(()) |
| 416 | Self: 'a; | ||
| 417 | |||
| 418 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | ||
| 419 | futures_util::future::ready(Ok(())) | ||
| 420 | } | 394 | } |
| 421 | } | 395 | } |
| 422 | 396 | ||
| @@ -425,12 +399,8 @@ mod io_impls { | |||
| 425 | } | 399 | } |
| 426 | 400 | ||
| 427 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Read for Reader<'_, M, N> { | 401 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Read for Reader<'_, M, N> { |
| 428 | type ReadFuture<'a> = impl Future<Output = Result<usize, Self::Error>> + 'a | 402 | async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { |
| 429 | where | 403 | Ok(Reader::read(self, buf).await) |
| 430 | Self: 'a; | ||
| 431 | |||
| 432 | fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { | ||
| 433 | Reader::read(self, buf).map(Ok) | ||
| 434 | } | 404 | } |
| 435 | } | 405 | } |
| 436 | 406 | ||
| @@ -439,20 +409,12 @@ mod io_impls { | |||
| 439 | } | 409 | } |
| 440 | 410 | ||
| 441 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Write for Writer<'_, M, N> { | 411 | impl<M: RawMutex, const N: usize> embedded_io::asynch::Write for Writer<'_, M, N> { |
| 442 | type WriteFuture<'a> = impl Future<Output = Result<usize, Self::Error>> + 'a | 412 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { |
| 443 | where | 413 | Ok(Writer::write(self, buf).await) |
| 444 | Self: 'a; | ||
| 445 | |||
| 446 | fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { | ||
| 447 | Writer::write(self, buf).map(Ok) | ||
| 448 | } | 414 | } |
| 449 | 415 | ||
| 450 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a | 416 | async fn flush(&mut self) -> Result<(), Self::Error> { |
| 451 | where | 417 | Ok(()) |
| 452 | Self: 'a; | ||
| 453 | |||
| 454 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | ||
| 455 | futures_util::future::ready(Ok(())) | ||
| 456 | } | 418 | } |
| 457 | } | 419 | } |
| 458 | } | 420 | } |
