Skip to content

Commit a0f297c

Browse files
committed
Remove feature(impl_trait_projections) from async traits.
1 parent 26740bb commit a0f297c

File tree

31 files changed

+136
-133
lines changed

31 files changed

+136
-133
lines changed

embassy-embedded-hal/src/flash/partition/asynch.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<M: RawMutex, T: NorFlash> ErrorType for Partition<'_, M, T> {
4949
impl<M: RawMutex, T: NorFlash> ReadNorFlash for Partition<'_, M, T> {
5050
const READ_SIZE: usize = T::READ_SIZE;
5151

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

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

79-
async fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> {
79+
async fn erase(&mut self, from: u32, to: u32) -> Result<(), Error<T::Error>> {
8080
if to > self.size {
8181
return Err(Error::OutOfBounds);
8282
}

embassy-embedded-hal/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![cfg_attr(not(feature = "std"), no_std)]
2-
#![cfg_attr(feature = "nightly", feature(async_fn_in_trait, impl_trait_projections, try_blocks))]
2+
#![cfg_attr(feature = "nightly", feature(async_fn_in_trait, try_blocks))]
33
#![warn(missing_docs)]
44

55
//! Utilities to use `embedded-hal` traits with Embassy.

embassy-embedded-hal/src/shared_bus/asynch/i2c.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,11 @@ where
151151
Ok(())
152152
}
153153

154-
async fn transaction(&mut self, address: u8, operations: &mut [i2c::Operation<'_>]) -> Result<(), Self::Error> {
154+
async fn transaction(
155+
&mut self,
156+
address: u8,
157+
operations: &mut [i2c::Operation<'_>],
158+
) -> Result<(), I2cDeviceError<BUS::Error>> {
155159
let mut bus = self.bus.lock().await;
156160
bus.set_config(&self.config);
157161
bus.transaction(address, operations)

embassy-embedded-hal/src/shared_bus/asynch/spi.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ where
6262
BUS: spi::SpiBus,
6363
CS: OutputPin,
6464
{
65-
async fn transaction(&mut self, operations: &mut [spi::Operation<'_, u8>]) -> Result<(), Self::Error> {
65+
async fn transaction(
66+
&mut self,
67+
operations: &mut [spi::Operation<'_, u8>],
68+
) -> Result<(), SpiDeviceError<BUS::Error, CS::Error>> {
6669
let mut bus = self.bus.lock().await;
6770
self.cs.set_low().map_err(SpiDeviceError::Cs)?;
6871

@@ -128,7 +131,10 @@ where
128131
BUS: spi::SpiBus + SetConfig,
129132
CS: OutputPin,
130133
{
131-
async fn transaction(&mut self, operations: &mut [spi::Operation<'_, u8>]) -> Result<(), Self::Error> {
134+
async fn transaction(
135+
&mut self,
136+
operations: &mut [spi::Operation<'_, u8>],
137+
) -> Result<(), SpiDeviceError<BUS::Error, CS::Error>> {
132138
let mut bus = self.bus.lock().await;
133139
bus.set_config(&self.config);
134140
self.cs.set_low().map_err(SpiDeviceError::Cs)?;

embassy-lora/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![no_std]
2-
#![feature(async_fn_in_trait, impl_trait_projections)]
2+
#![feature(async_fn_in_trait)]
33
//! embassy-lora holds LoRa-specific functionality.
44
55
pub(crate) mod fmt;

embassy-net/src/dns.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ where
7979
&self,
8080
host: &str,
8181
addr_type: embedded_nal_async::AddrType,
82-
) -> Result<embedded_nal_async::IpAddr, Self::Error> {
82+
) -> Result<embedded_nal_async::IpAddr, Error> {
8383
use embedded_nal_async::{AddrType, IpAddr};
8484
let qtype = match addr_type {
8585
AddrType::IPv6 => DnsQueryType::Aaaa,
@@ -98,10 +98,7 @@ where
9898
}
9999
}
100100

101-
async fn get_host_by_address(
102-
&self,
103-
_addr: embedded_nal_async::IpAddr,
104-
) -> Result<heapless::String<256>, Self::Error> {
101+
async fn get_host_by_address(&self, _addr: embedded_nal_async::IpAddr) -> Result<heapless::String<256>, Error> {
105102
todo!()
106103
}
107104
}

embassy-net/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![cfg_attr(not(feature = "std"), no_std)]
2-
#![cfg_attr(feature = "nightly", feature(async_fn_in_trait, impl_trait_projections))]
2+
#![cfg_attr(feature = "nightly", feature(async_fn_in_trait))]
33
#![warn(missing_docs)]
44
#![doc = include_str!("../README.md")]
55

embassy-net/src/tcp.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -536,17 +536,17 @@ mod embedded_io_impls {
536536
}
537537

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

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

549-
async fn flush(&mut self) -> Result<(), Self::Error> {
549+
async fn flush(&mut self) -> Result<(), Error> {
550550
self.io.flush().await
551551
}
552552
}
@@ -556,7 +556,7 @@ mod embedded_io_impls {
556556
}
557557

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

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

573-
async fn flush(&mut self) -> Result<(), Self::Error> {
573+
async fn flush(&mut self) -> Result<(), Error> {
574574
self.io.flush().await
575575
}
576576
}
@@ -612,7 +612,7 @@ pub mod client {
612612
async fn connect<'a>(
613613
&'a self,
614614
remote: embedded_nal_async::SocketAddr,
615-
) -> Result<Self::Connection<'a>, Self::Error>
615+
) -> Result<TcpConnection<'a, N, TX_SZ, RX_SZ>, Error>
616616
where
617617
Self: 'a,
618618
{
@@ -673,19 +673,19 @@ pub mod client {
673673
impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> embedded_io_async::Read
674674
for TcpConnection<'d, N, TX_SZ, RX_SZ>
675675
{
676-
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
676+
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error> {
677677
self.socket.read(buf).await
678678
}
679679
}
680680

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

688-
async fn flush(&mut self) -> Result<(), Self::Error> {
688+
async fn flush(&mut self) -> Result<(), Error> {
689689
self.socket.flush().await
690690
}
691691
}

embassy-nrf/src/buffered_uarte.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -591,19 +591,19 @@ mod _embedded_io {
591591
}
592592

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

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

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

@@ -613,7 +613,7 @@ mod _embedded_io {
613613
}
614614

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

@@ -623,21 +623,21 @@ mod _embedded_io {
623623
}
624624

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

630-
async fn flush(&mut self) -> Result<(), Self::Error> {
630+
async fn flush(&mut self) -> Result<(), Error> {
631631
self.inner_flush().await
632632
}
633633
}
634634

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

640-
async fn flush(&mut self) -> Result<(), Self::Error> {
640+
async fn flush(&mut self) -> Result<(), Error> {
641641
self.inner.inner_flush().await
642642
}
643643
}

embassy-nrf/src/gpiote.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -515,45 +515,45 @@ mod eha {
515515
use super::*;
516516

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

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

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

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

534-
async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> {
534+
async fn wait_for_any_edge(&mut self) -> Result<(), Infallible> {
535535
Ok(self.wait_for_any_edge().await)
536536
}
537537
}
538538

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

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

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

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

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

embassy-nrf/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![no_std]
2-
#![cfg_attr(feature = "nightly", feature(async_fn_in_trait, impl_trait_projections))]
2+
#![cfg_attr(feature = "nightly", feature(async_fn_in_trait))]
33
#![doc = include_str!("../README.md")]
44
#![warn(missing_docs)]
55

embassy-nrf/src/qspi.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -595,11 +595,11 @@ mod _eh1 {
595595
const WRITE_SIZE: usize = <Self as NorFlash>::WRITE_SIZE;
596596
const ERASE_SIZE: usize = <Self as NorFlash>::ERASE_SIZE;
597597

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

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

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

embassy-nrf/src/twim.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -864,22 +864,22 @@ mod eh1 {
864864
mod eha {
865865
use super::*;
866866
impl<'d, T: Instance> embedded_hal_async::i2c::I2c for Twim<'d, T> {
867-
async fn read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Self::Error> {
867+
async fn read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Error> {
868868
self.read(address, read).await
869869
}
870870

871-
async fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Self::Error> {
871+
async fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Error> {
872872
self.write(address, write).await
873873
}
874-
async fn write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error> {
874+
async fn write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Error> {
875875
self.write_read(address, write, read).await
876876
}
877877

878878
async fn transaction(
879879
&mut self,
880880
address: u8,
881881
operations: &mut [embedded_hal_1::i2c::Operation<'_>],
882-
) -> Result<(), Self::Error> {
882+
) -> Result<(), Error> {
883883
let _ = address;
884884
let _ = operations;
885885
todo!()

embassy-rp/src/flash.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ impl<'d, T: Instance, const FLASH_SIZE: usize> embedded_storage_async::nor_flash
390390
{
391391
const READ_SIZE: usize = ASYNC_READ_SIZE;
392392

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

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

408408
const ERASE_SIZE: usize = ERASE_SIZE;
409409

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

414-
async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> {
414+
async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> {
415415
self.blocking_write(offset, bytes)
416416
}
417417
}

0 commit comments

Comments
 (0)