diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-11-29 17:23:48 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2023-11-29 17:26:33 +0100 |
| commit | c6989dfbca51787146f50270c671af9db434f577 (patch) | |
| tree | 5974a8ec41c108d5208e4f68027b918d424a2046 /embassy-sync/src/pipe.rs | |
| parent | 384bad7bfaa1f2415baf2cd3b69ebf36dc0a02d7 (diff) | |
Remove nightly and unstable-traits features in preparation for 1.75.
Diffstat (limited to 'embassy-sync/src/pipe.rs')
| -rw-r--r-- | embassy-sync/src/pipe.rs | 104 |
1 files changed, 49 insertions, 55 deletions
diff --git a/embassy-sync/src/pipe.rs b/embassy-sync/src/pipe.rs index ec0cbbf2a..42fe8ebd0 100644 --- a/embassy-sync/src/pipe.rs +++ b/embassy-sync/src/pipe.rs | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | //! Async byte stream pipe. | 1 | //! Async byte stream pipe. |
| 2 | 2 | ||
| 3 | use core::cell::{RefCell, UnsafeCell}; | 3 | use core::cell::{RefCell, UnsafeCell}; |
| 4 | use core::convert::Infallible; | ||
| 4 | use core::future::Future; | 5 | use core::future::Future; |
| 5 | use core::ops::Range; | 6 | use core::ops::Range; |
| 6 | use core::pin::Pin; | 7 | use core::pin::Pin; |
| @@ -457,84 +458,77 @@ where | |||
| 457 | } | 458 | } |
| 458 | } | 459 | } |
| 459 | 460 | ||
| 460 | #[cfg(feature = "nightly")] | 461 | impl<M: RawMutex, const N: usize> embedded_io_async::ErrorType for Pipe<M, N> { |
| 461 | mod io_impls { | 462 | type Error = Infallible; |
| 462 | use core::convert::Infallible; | 463 | } |
| 463 | 464 | ||
| 464 | use super::*; | 465 | impl<M: RawMutex, const N: usize> embedded_io_async::Read for Pipe<M, N> { |
| 466 | async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { | ||
| 467 | Ok(Pipe::read(self, buf).await) | ||
| 468 | } | ||
| 469 | } | ||
| 465 | 470 | ||
| 466 | impl<M: RawMutex, const N: usize> embedded_io_async::ErrorType for Pipe<M, N> { | 471 | impl<M: RawMutex, const N: usize> embedded_io_async::Write for Pipe<M, N> { |
| 467 | type Error = Infallible; | 472 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { |
| 473 | Ok(Pipe::write(self, buf).await) | ||
| 468 | } | 474 | } |
| 469 | 475 | ||
| 470 | impl<M: RawMutex, const N: usize> embedded_io_async::Read for Pipe<M, N> { | 476 | async fn flush(&mut self) -> Result<(), Self::Error> { |
| 471 | async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { | 477 | Ok(()) |
| 472 | Ok(Pipe::read(self, buf).await) | ||
| 473 | } | ||
| 474 | } | 478 | } |
| 479 | } | ||
| 475 | 480 | ||
| 476 | impl<M: RawMutex, const N: usize> embedded_io_async::Write for Pipe<M, N> { | 481 | impl<M: RawMutex, const N: usize> embedded_io_async::ErrorType for &Pipe<M, N> { |
| 477 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { | 482 | type Error = Infallible; |
| 478 | Ok(Pipe::write(self, buf).await) | 483 | } |
| 479 | } | ||
| 480 | 484 | ||
| 481 | async fn flush(&mut self) -> Result<(), Self::Error> { | 485 | impl<M: RawMutex, const N: usize> embedded_io_async::Read for &Pipe<M, N> { |
| 482 | Ok(()) | 486 | async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { |
| 483 | } | 487 | Ok(Pipe::read(self, buf).await) |
| 484 | } | 488 | } |
| 489 | } | ||
| 485 | 490 | ||
| 486 | impl<M: RawMutex, const N: usize> embedded_io_async::ErrorType for &Pipe<M, N> { | 491 | impl<M: RawMutex, const N: usize> embedded_io_async::Write for &Pipe<M, N> { |
| 487 | type Error = Infallible; | 492 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { |
| 493 | Ok(Pipe::write(self, buf).await) | ||
| 488 | } | 494 | } |
| 489 | 495 | ||
| 490 | impl<M: RawMutex, const N: usize> embedded_io_async::Read for &Pipe<M, N> { | 496 | async fn flush(&mut self) -> Result<(), Self::Error> { |
| 491 | async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { | 497 | Ok(()) |
| 492 | Ok(Pipe::read(self, buf).await) | ||
| 493 | } | ||
| 494 | } | 498 | } |
| 499 | } | ||
| 495 | 500 | ||
| 496 | impl<M: RawMutex, const N: usize> embedded_io_async::Write for &Pipe<M, N> { | 501 | impl<M: RawMutex, const N: usize> embedded_io_async::ErrorType for Reader<'_, M, N> { |
| 497 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { | 502 | type Error = Infallible; |
| 498 | Ok(Pipe::write(self, buf).await) | 503 | } |
| 499 | } | ||
| 500 | 504 | ||
| 501 | async fn flush(&mut self) -> Result<(), Self::Error> { | 505 | impl<M: RawMutex, const N: usize> embedded_io_async::Read for Reader<'_, M, N> { |
| 502 | Ok(()) | 506 | async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { |
| 503 | } | 507 | Ok(Reader::read(self, buf).await) |
| 504 | } | 508 | } |
| 509 | } | ||
| 505 | 510 | ||
| 506 | impl<M: RawMutex, const N: usize> embedded_io_async::ErrorType for Reader<'_, M, N> { | 511 | impl<M: RawMutex, const N: usize> embedded_io_async::BufRead for Reader<'_, M, N> { |
| 507 | type Error = Infallible; | 512 | async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { |
| 513 | Ok(Reader::fill_buf(self).await) | ||
| 508 | } | 514 | } |
| 509 | 515 | ||
| 510 | impl<M: RawMutex, const N: usize> embedded_io_async::Read for Reader<'_, M, N> { | 516 | fn consume(&mut self, amt: usize) { |
| 511 | async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { | 517 | Reader::consume(self, amt) |
| 512 | Ok(Reader::read(self, buf).await) | ||
| 513 | } | ||
| 514 | } | 518 | } |
| 519 | } | ||
| 515 | 520 | ||
| 516 | impl<M: RawMutex, const N: usize> embedded_io_async::BufRead for Reader<'_, M, N> { | 521 | impl<M: RawMutex, const N: usize> embedded_io_async::ErrorType for Writer<'_, M, N> { |
| 517 | async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { | 522 | type Error = Infallible; |
| 518 | Ok(Reader::fill_buf(self).await) | 523 | } |
| 519 | } | ||
| 520 | |||
| 521 | fn consume(&mut self, amt: usize) { | ||
| 522 | Reader::consume(self, amt) | ||
| 523 | } | ||
| 524 | } | ||
| 525 | 524 | ||
| 526 | impl<M: RawMutex, const N: usize> embedded_io_async::ErrorType for Writer<'_, M, N> { | 525 | impl<M: RawMutex, const N: usize> embedded_io_async::Write for Writer<'_, M, N> { |
| 527 | type Error = Infallible; | 526 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { |
| 527 | Ok(Writer::write(self, buf).await) | ||
| 528 | } | 528 | } |
| 529 | 529 | ||
| 530 | impl<M: RawMutex, const N: usize> embedded_io_async::Write for Writer<'_, M, N> { | 530 | async fn flush(&mut self) -> Result<(), Self::Error> { |
| 531 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { | 531 | Ok(()) |
| 532 | Ok(Writer::write(self, buf).await) | ||
| 533 | } | ||
| 534 | |||
| 535 | async fn flush(&mut self) -> Result<(), Self::Error> { | ||
| 536 | Ok(()) | ||
| 537 | } | ||
| 538 | } | 532 | } |
| 539 | } | 533 | } |
| 540 | 534 | ||
