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 | |
| parent | 384bad7bfaa1f2415baf2cd3b69ebf36dc0a02d7 (diff) | |
Remove nightly and unstable-traits features in preparation for 1.75.
Diffstat (limited to 'embassy-sync')
| -rw-r--r-- | embassy-sync/Cargo.toml | 7 | ||||
| -rw-r--r-- | embassy-sync/build.rs | 15 | ||||
| -rw-r--r-- | embassy-sync/src/lib.rs | 5 | ||||
| -rw-r--r-- | embassy-sync/src/pipe.rs | 104 |
4 files changed, 68 insertions, 63 deletions
diff --git a/embassy-sync/Cargo.toml b/embassy-sync/Cargo.toml index ffcd13d9f..6588406a1 100644 --- a/embassy-sync/Cargo.toml +++ b/embassy-sync/Cargo.toml | |||
| @@ -16,14 +16,9 @@ categories = [ | |||
| 16 | [package.metadata.embassy_docs] | 16 | [package.metadata.embassy_docs] |
| 17 | src_base = "https://github.com/embassy-rs/embassy/blob/embassy-sync-v$VERSION/embassy-sync/src/" | 17 | src_base = "https://github.com/embassy-rs/embassy/blob/embassy-sync-v$VERSION/embassy-sync/src/" |
| 18 | src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-sync/src/" | 18 | src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-sync/src/" |
| 19 | features = ["nightly"] | ||
| 20 | target = "thumbv7em-none-eabi" | 19 | target = "thumbv7em-none-eabi" |
| 21 | 20 | ||
| 22 | [package.metadata.docs.rs] | ||
| 23 | features = ["nightly"] | ||
| 24 | |||
| 25 | [features] | 21 | [features] |
| 26 | nightly = ["dep:embedded-io-async"] | ||
| 27 | std = [] | 22 | std = [] |
| 28 | turbowakers = [] | 23 | turbowakers = [] |
| 29 | 24 | ||
| @@ -35,7 +30,7 @@ futures-util = { version = "0.3.17", default-features = false } | |||
| 35 | critical-section = "1.1" | 30 | critical-section = "1.1" |
| 36 | heapless = "0.8" | 31 | heapless = "0.8" |
| 37 | cfg-if = "1.0.0" | 32 | cfg-if = "1.0.0" |
| 38 | embedded-io-async = { version = "0.6.1", optional = true } | 33 | embedded-io-async = { version = "0.6.1" } |
| 39 | 34 | ||
| 40 | [dev-dependencies] | 35 | [dev-dependencies] |
| 41 | futures-executor = { version = "0.3.17", features = [ "thread-pool" ] } | 36 | futures-executor = { version = "0.3.17", features = [ "thread-pool" ] } |
diff --git a/embassy-sync/build.rs b/embassy-sync/build.rs index 6fe82b44f..0a796b881 100644 --- a/embassy-sync/build.rs +++ b/embassy-sync/build.rs | |||
| @@ -1,6 +1,21 @@ | |||
| 1 | use std::env; | 1 | use std::env; |
| 2 | use std::ffi::OsString; | ||
| 3 | use std::process::Command; | ||
| 2 | 4 | ||
| 3 | fn main() { | 5 | fn main() { |
| 6 | println!("cargo:rerun-if-changed=build.rs"); | ||
| 7 | |||
| 8 | let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc")); | ||
| 9 | |||
| 10 | let output = Command::new(rustc) | ||
| 11 | .arg("--version") | ||
| 12 | .output() | ||
| 13 | .expect("failed to run `rustc --version`"); | ||
| 14 | |||
| 15 | if String::from_utf8_lossy(&output.stdout).contains("nightly") { | ||
| 16 | println!("cargo:rustc-cfg=nightly"); | ||
| 17 | } | ||
| 18 | |||
| 4 | let target = env::var("TARGET").unwrap(); | 19 | let target = env::var("TARGET").unwrap(); |
| 5 | 20 | ||
| 6 | if target.starts_with("thumbv6m-") { | 21 | if target.starts_with("thumbv6m-") { |
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 | ||
| 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 | ||
