Skip to content

Remove feature(impl_trait_projections) from async traits. #1872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions embassy-embedded-hal/src/flash/partition/asynch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl<M: RawMutex, T: NorFlash> ErrorType for Partition<'_, M, T> {
impl<M: RawMutex, T: NorFlash> ReadNorFlash for Partition<'_, M, T> {
const READ_SIZE: usize = T::READ_SIZE;

async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> {
async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error<T::Error>> {
if offset + bytes.len() as u32 > self.size {
return Err(Error::OutOfBounds);
}
Expand All @@ -67,7 +67,7 @@ impl<M: RawMutex, T: NorFlash> NorFlash for Partition<'_, M, T> {
const WRITE_SIZE: usize = T::WRITE_SIZE;
const ERASE_SIZE: usize = T::ERASE_SIZE;

async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> {
async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error<T::Error>> {
if offset + bytes.len() as u32 > self.size {
return Err(Error::OutOfBounds);
}
Expand All @@ -76,7 +76,7 @@ impl<M: RawMutex, T: NorFlash> NorFlash for Partition<'_, M, T> {
flash.write(self.offset + offset, bytes).await.map_err(Error::Flash)
}

async fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> {
async fn erase(&mut self, from: u32, to: u32) -> Result<(), Error<T::Error>> {
if to > self.size {
return Err(Error::OutOfBounds);
}
Expand Down
2 changes: 1 addition & 1 deletion embassy-embedded-hal/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(feature = "nightly", feature(async_fn_in_trait, impl_trait_projections, try_blocks))]
#![cfg_attr(feature = "nightly", feature(async_fn_in_trait, try_blocks))]
#![warn(missing_docs)]

//! Utilities to use `embedded-hal` traits with Embassy.
Expand Down
6 changes: 5 additions & 1 deletion embassy-embedded-hal/src/shared_bus/asynch/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ where
Ok(())
}

async fn transaction(&mut self, address: u8, operations: &mut [i2c::Operation<'_>]) -> Result<(), Self::Error> {
async fn transaction(
&mut self,
address: u8,
operations: &mut [i2c::Operation<'_>],
) -> Result<(), I2cDeviceError<BUS::Error>> {
let mut bus = self.bus.lock().await;
bus.set_config(&self.config);
bus.transaction(address, operations)
Expand Down
10 changes: 8 additions & 2 deletions embassy-embedded-hal/src/shared_bus/asynch/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ where
BUS: spi::SpiBus,
CS: OutputPin,
{
async fn transaction(&mut self, operations: &mut [spi::Operation<'_, u8>]) -> Result<(), Self::Error> {
async fn transaction(
&mut self,
operations: &mut [spi::Operation<'_, u8>],
) -> Result<(), SpiDeviceError<BUS::Error, CS::Error>> {
let mut bus = self.bus.lock().await;
self.cs.set_low().map_err(SpiDeviceError::Cs)?;

Expand Down Expand Up @@ -128,7 +131,10 @@ where
BUS: spi::SpiBus + SetConfig,
CS: OutputPin,
{
async fn transaction(&mut self, operations: &mut [spi::Operation<'_, u8>]) -> Result<(), Self::Error> {
async fn transaction(
&mut self,
operations: &mut [spi::Operation<'_, u8>],
) -> Result<(), SpiDeviceError<BUS::Error, CS::Error>> {
let mut bus = self.bus.lock().await;
bus.set_config(&self.config);
self.cs.set_low().map_err(SpiDeviceError::Cs)?;
Expand Down
2 changes: 1 addition & 1 deletion embassy-lora/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![no_std]
#![feature(async_fn_in_trait, impl_trait_projections)]
#![feature(async_fn_in_trait)]
//! embassy-lora holds LoRa-specific functionality.

pub(crate) mod fmt;
Expand Down
7 changes: 2 additions & 5 deletions embassy-net/src/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ where
&self,
host: &str,
addr_type: embedded_nal_async::AddrType,
) -> Result<embedded_nal_async::IpAddr, Self::Error> {
) -> Result<embedded_nal_async::IpAddr, Error> {
use embedded_nal_async::{AddrType, IpAddr};
let qtype = match addr_type {
AddrType::IPv6 => DnsQueryType::Aaaa,
Expand All @@ -98,10 +98,7 @@ where
}
}

async fn get_host_by_address(
&self,
_addr: embedded_nal_async::IpAddr,
) -> Result<heapless::String<256>, Self::Error> {
async fn get_host_by_address(&self, _addr: embedded_nal_async::IpAddr) -> Result<heapless::String<256>, Error> {
todo!()
}
}
2 changes: 1 addition & 1 deletion embassy-net/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(feature = "nightly", feature(async_fn_in_trait, impl_trait_projections))]
#![cfg_attr(feature = "nightly", feature(async_fn_in_trait))]
#![warn(missing_docs)]
#![doc = include_str!("../README.md")]

Expand Down
20 changes: 10 additions & 10 deletions embassy-net/src/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,17 +536,17 @@ mod embedded_io_impls {
}

impl<'d> embedded_io_async::Read for TcpSocket<'d> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error> {
self.io.read(buf).await
}
}

impl<'d> embedded_io_async::Write for TcpSocket<'d> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, Error> {
self.io.write(buf).await
}

async fn flush(&mut self) -> Result<(), Self::Error> {
async fn flush(&mut self) -> Result<(), Error> {
self.io.flush().await
}
}
Expand All @@ -556,7 +556,7 @@ mod embedded_io_impls {
}

impl<'d> embedded_io_async::Read for TcpReader<'d> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error> {
self.io.read(buf).await
}
}
Expand All @@ -566,11 +566,11 @@ mod embedded_io_impls {
}

impl<'d> embedded_io_async::Write for TcpWriter<'d> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, Error> {
self.io.write(buf).await
}

async fn flush(&mut self) -> Result<(), Self::Error> {
async fn flush(&mut self) -> Result<(), Error> {
self.io.flush().await
}
}
Expand Down Expand Up @@ -612,7 +612,7 @@ pub mod client {
async fn connect<'a>(
&'a self,
remote: embedded_nal_async::SocketAddr,
) -> Result<Self::Connection<'a>, Self::Error>
) -> Result<TcpConnection<'a, N, TX_SZ, RX_SZ>, Error>
where
Self: 'a,
{
Expand Down Expand Up @@ -673,19 +673,19 @@ pub mod client {
impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> embedded_io_async::Read
for TcpConnection<'d, N, TX_SZ, RX_SZ>
{
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error> {
self.socket.read(buf).await
}
}

impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> embedded_io_async::Write
for TcpConnection<'d, N, TX_SZ, RX_SZ>
{
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, Error> {
self.socket.write(buf).await
}

async fn flush(&mut self) -> Result<(), Self::Error> {
async fn flush(&mut self) -> Result<(), Error> {
self.socket.flush().await
}
}
Expand Down
16 changes: 8 additions & 8 deletions embassy-nrf/src/buffered_uarte.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,19 +591,19 @@ mod _embedded_io {
}

impl<'d, U: UarteInstance, T: TimerInstance> embedded_io_async::Read for BufferedUarte<'d, U, T> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error> {
self.inner_read(buf).await
}
}

impl<'u, 'd: 'u, U: UarteInstance, T: TimerInstance> embedded_io_async::Read for BufferedUarteRx<'u, 'd, U, T> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error> {
self.inner.inner_read(buf).await
}
}

impl<'d, U: UarteInstance, T: TimerInstance> embedded_io_async::BufRead for BufferedUarte<'d, U, T> {
async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> {
async fn fill_buf(&mut self) -> Result<&[u8], Error> {
self.inner_fill_buf().await
}

Expand All @@ -613,7 +613,7 @@ mod _embedded_io {
}

impl<'u, 'd: 'u, U: UarteInstance, T: TimerInstance> embedded_io_async::BufRead for BufferedUarteRx<'u, 'd, U, T> {
async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> {
async fn fill_buf(&mut self) -> Result<&[u8], Error> {
self.inner.inner_fill_buf().await
}

Expand All @@ -623,21 +623,21 @@ mod _embedded_io {
}

impl<'d, U: UarteInstance, T: TimerInstance> embedded_io_async::Write for BufferedUarte<'d, U, T> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, Error> {
self.inner_write(buf).await
}

async fn flush(&mut self) -> Result<(), Self::Error> {
async fn flush(&mut self) -> Result<(), Error> {
self.inner_flush().await
}
}

impl<'u, 'd: 'u, U: UarteInstance, T: TimerInstance> embedded_io_async::Write for BufferedUarteTx<'u, 'd, U, T> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, Error> {
self.inner.inner_write(buf).await
}

async fn flush(&mut self) -> Result<(), Self::Error> {
async fn flush(&mut self) -> Result<(), Error> {
self.inner.inner_flush().await
}
}
Expand Down
20 changes: 10 additions & 10 deletions embassy-nrf/src/gpiote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,45 +515,45 @@ mod eha {
use super::*;

impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> {
async fn wait_for_high(&mut self) -> Result<(), Self::Error> {
async fn wait_for_high(&mut self) -> Result<(), Infallible> {
Ok(self.wait_for_high().await)
}

async fn wait_for_low(&mut self) -> Result<(), Self::Error> {
async fn wait_for_low(&mut self) -> Result<(), Infallible> {
Ok(self.wait_for_low().await)
}

async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> {
async fn wait_for_rising_edge(&mut self) -> Result<(), Infallible> {
Ok(self.wait_for_rising_edge().await)
}

async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> {
async fn wait_for_falling_edge(&mut self) -> Result<(), Infallible> {
Ok(self.wait_for_falling_edge().await)
}

async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> {
async fn wait_for_any_edge(&mut self) -> Result<(), Infallible> {
Ok(self.wait_for_any_edge().await)
}
}

impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Flex<'d, T> {
async fn wait_for_high(&mut self) -> Result<(), Self::Error> {
async fn wait_for_high(&mut self) -> Result<(), Infallible> {
Ok(self.wait_for_high().await)
}

async fn wait_for_low(&mut self) -> Result<(), Self::Error> {
async fn wait_for_low(&mut self) -> Result<(), Infallible> {
Ok(self.wait_for_low().await)
}

async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> {
async fn wait_for_rising_edge(&mut self) -> Result<(), Infallible> {
Ok(self.wait_for_rising_edge().await)
}

async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> {
async fn wait_for_falling_edge(&mut self) -> Result<(), Infallible> {
Ok(self.wait_for_falling_edge().await)
}

async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> {
async fn wait_for_any_edge(&mut self) -> Result<(), Infallible> {
Ok(self.wait_for_any_edge().await)
}
}
Expand Down
2 changes: 1 addition & 1 deletion embassy-nrf/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![no_std]
#![cfg_attr(feature = "nightly", feature(async_fn_in_trait, impl_trait_projections))]
#![cfg_attr(feature = "nightly", feature(async_fn_in_trait))]
#![doc = include_str!("../README.md")]
#![warn(missing_docs)]

Expand Down
6 changes: 3 additions & 3 deletions embassy-nrf/src/qspi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,11 +595,11 @@ mod _eh1 {
const WRITE_SIZE: usize = <Self as NorFlash>::WRITE_SIZE;
const ERASE_SIZE: usize = <Self as NorFlash>::ERASE_SIZE;

async fn write(&mut self, offset: u32, data: &[u8]) -> Result<(), Self::Error> {
async fn write(&mut self, offset: u32, data: &[u8]) -> Result<(), Error> {
self.write(offset, data).await
}

async fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> {
async fn erase(&mut self, from: u32, to: u32) -> Result<(), Error> {
for address in (from..to).step_by(<Self as AsyncNorFlash>::ERASE_SIZE) {
self.erase(address).await?
}
Expand All @@ -609,7 +609,7 @@ mod _eh1 {

impl<'d, T: Instance> AsyncReadNorFlash for Qspi<'d, T> {
const READ_SIZE: usize = 4;
async fn read(&mut self, address: u32, data: &mut [u8]) -> Result<(), Self::Error> {
async fn read(&mut self, address: u32, data: &mut [u8]) -> Result<(), Error> {
self.read(address, data).await
}

Expand Down
8 changes: 4 additions & 4 deletions embassy-nrf/src/twim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -864,22 +864,22 @@ mod eh1 {
mod eha {
use super::*;
impl<'d, T: Instance> embedded_hal_async::i2c::I2c for Twim<'d, T> {
async fn read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Self::Error> {
async fn read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Error> {
self.read(address, read).await
}

async fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Self::Error> {
async fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Error> {
self.write(address, write).await
}
async fn write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error> {
async fn write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Error> {
self.write_read(address, write, read).await
}

async fn transaction(
&mut self,
address: u8,
operations: &mut [embedded_hal_1::i2c::Operation<'_>],
) -> Result<(), Self::Error> {
) -> Result<(), Error> {
let _ = address;
let _ = operations;
todo!()
Expand Down
6 changes: 3 additions & 3 deletions embassy-rp/src/flash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ impl<'d, T: Instance, const FLASH_SIZE: usize> embedded_storage_async::nor_flash
{
const READ_SIZE: usize = ASYNC_READ_SIZE;

async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> {
async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> {
self.read(offset, bytes).await
}

Expand All @@ -407,11 +407,11 @@ impl<'d, T: Instance, const FLASH_SIZE: usize> embedded_storage_async::nor_flash

const ERASE_SIZE: usize = ERASE_SIZE;

async fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> {
async fn erase(&mut self, from: u32, to: u32) -> Result<(), Error> {
self.blocking_erase(from, to)
}

async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> {
async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> {
self.blocking_write(offset, bytes)
}
}
Expand Down
Loading