aboutsummaryrefslogtreecommitdiff
path: root/embassy-sync/src
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-11-29 17:23:48 +0100
committerDario Nieuwenhuis <[email protected]>2023-11-29 17:26:33 +0100
commitc6989dfbca51787146f50270c671af9db434f577 (patch)
tree5974a8ec41c108d5208e4f68027b918d424a2046 /embassy-sync/src
parent384bad7bfaa1f2415baf2cd3b69ebf36dc0a02d7 (diff)
Remove nightly and unstable-traits features in preparation for 1.75.
Diffstat (limited to 'embassy-sync/src')
-rw-r--r--embassy-sync/src/lib.rs5
-rw-r--r--embassy-sync/src/pipe.rs104
2 files changed, 52 insertions, 57 deletions
diff --git a/embassy-sync/src/lib.rs b/embassy-sync/src/lib.rs
index 3ffcb9135..b0ccfde57 100644
--- a/embassy-sync/src/lib.rs
+++ b/embassy-sync/src/lib.rs
@@ -1,6 +1,7 @@
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(async_fn_in_trait, impl_trait_projections))] 2#![cfg_attr(nightly, feature(async_fn_in_trait, impl_trait_projections))]
3#![cfg_attr(feature = "nightly", allow(stable_features, unknown_lints, async_fn_in_trait))] 3#![cfg_attr(nightly, allow(stable_features, unknown_lints))]
4#![allow(async_fn_in_trait)]
4#![allow(clippy::new_without_default)] 5#![allow(clippy::new_without_default)]
5#![doc = include_str!("../README.md")] 6#![doc = include_str!("../README.md")]
6#![warn(missing_docs)] 7#![warn(missing_docs)]
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
3use core::cell::{RefCell, UnsafeCell}; 3use core::cell::{RefCell, UnsafeCell};
4use core::convert::Infallible;
4use core::future::Future; 5use core::future::Future;
5use core::ops::Range; 6use core::ops::Range;
6use core::pin::Pin; 7use core::pin::Pin;
@@ -457,84 +458,77 @@ where
457 } 458 }
458} 459}
459 460
460#[cfg(feature = "nightly")] 461impl<M: RawMutex, const N: usize> embedded_io_async::ErrorType for Pipe<M, N> {
461mod io_impls { 462 type Error = Infallible;
462 use core::convert::Infallible; 463}
463 464
464 use super::*; 465impl<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> { 471impl<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> { 481impl<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> { 485impl<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> { 491impl<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> { 501impl<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> { 505impl<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> { 511impl<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> { 521impl<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> { 525impl<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