Merge #1079
1079: Async function in trait cleanup r=Dirbaio a=yodaldevoid Some issues I ran across after the AFIT stuff was merged. Co-authored-by: Gabriel Smith <ga29smith@gmail.com> Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
This commit is contained in:
commit
cea29d7de3
2
ci.sh
2
ci.sh
@ -36,6 +36,8 @@ cargo batch \
|
|||||||
--- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv7em-none-eabi --features nightly,log \
|
--- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv7em-none-eabi --features nightly,log \
|
||||||
--- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv7em-none-eabi --features nightly,defmt \
|
--- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv7em-none-eabi --features nightly,defmt \
|
||||||
--- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv6m-none-eabi --features nightly,defmt \
|
--- build --release --manifest-path embassy-executor/Cargo.toml --target thumbv6m-none-eabi --features nightly,defmt \
|
||||||
|
--- build --release --manifest-path embassy-sync/Cargo.toml --target thumbv6m-none-eabi --features nightly,defmt \
|
||||||
|
--- build --release --manifest-path embassy-time/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits,defmt,defmt-timestamp-uptime,tick-hz-32_768,generic-queue-8 \
|
||||||
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet,pool-16 \
|
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet,pool-16 \
|
||||||
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet,pool-16,unstable-traits \
|
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet,pool-16,unstable-traits \
|
||||||
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet,pool-16,nightly \
|
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet,pool-16,nightly \
|
||||||
|
@ -164,7 +164,7 @@ impl<'d, T: Instance> RealTimeClock<'d, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Errors that can occur on methods on [RtcClock]
|
/// Errors that can occur on methods on [RealTimeClock]
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum RtcError {
|
pub enum RtcError {
|
||||||
/// An invalid DateTime was given or stored on the hardware.
|
/// An invalid DateTime was given or stored on the hardware.
|
||||||
|
@ -638,7 +638,7 @@ impl<'d, T: Instance> driver::ControlPipe for ControlPipe<'d, T> {
|
|||||||
64
|
64
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn setup<'a>(&'a mut self) -> [u8; 8] {
|
async fn setup(&mut self) -> [u8; 8] {
|
||||||
loop {
|
loop {
|
||||||
trace!("SETUP read waiting");
|
trace!("SETUP read waiting");
|
||||||
let regs = T::regs();
|
let regs = T::regs();
|
||||||
|
@ -799,7 +799,7 @@ impl<'d, T: Instance> driver::ControlPipe for ControlPipe<'d, T> {
|
|||||||
usize::from(self.max_packet_size)
|
usize::from(self.max_packet_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn setup<'a>(&'a mut self) -> [u8; 8] {
|
async fn setup(&mut self) -> [u8; 8] {
|
||||||
loop {
|
loop {
|
||||||
trace!("SETUP read waiting");
|
trace!("SETUP read waiting");
|
||||||
poll_fn(|cx| {
|
poll_fn(|cx| {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)]
|
#![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)]
|
||||||
#![cfg_attr(feature = "nightly", feature(type_alias_impl_trait))]
|
#![cfg_attr(feature = "nightly", feature(async_fn_in_trait, impl_trait_projections))]
|
||||||
|
#![cfg_attr(feature = "nightly", allow(incomplete_features))]
|
||||||
#![allow(clippy::new_without_default)]
|
#![allow(clippy::new_without_default)]
|
||||||
#![doc = include_str!("../README.md")]
|
#![doc = include_str!("../README.md")]
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
|
@ -352,8 +352,6 @@ where
|
|||||||
mod io_impls {
|
mod io_impls {
|
||||||
use core::convert::Infallible;
|
use core::convert::Infallible;
|
||||||
|
|
||||||
use futures_util::FutureExt;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
impl<M: RawMutex, const N: usize> embedded_io::Io for Pipe<M, N> {
|
impl<M: RawMutex, const N: usize> embedded_io::Io for Pipe<M, N> {
|
||||||
@ -361,30 +359,18 @@ mod io_impls {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<M: RawMutex, const N: usize> embedded_io::asynch::Read for Pipe<M, N> {
|
impl<M: RawMutex, const N: usize> embedded_io::asynch::Read for Pipe<M, N> {
|
||||||
type ReadFuture<'a> = impl Future<Output = Result<usize, Self::Error>> + 'a
|
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
|
||||||
where
|
Ok(Pipe::read(self, buf).await)
|
||||||
Self: 'a;
|
|
||||||
|
|
||||||
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> {
|
|
||||||
Pipe::read(self, buf).map(Ok)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<M: RawMutex, const N: usize> embedded_io::asynch::Write for Pipe<M, N> {
|
impl<M: RawMutex, const N: usize> embedded_io::asynch::Write for Pipe<M, N> {
|
||||||
type WriteFuture<'a> = impl Future<Output = Result<usize, Self::Error>> + 'a
|
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
|
||||||
where
|
Ok(Pipe::write(self, buf).await)
|
||||||
Self: 'a;
|
|
||||||
|
|
||||||
fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> {
|
|
||||||
Pipe::write(self, buf).map(Ok)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a
|
async fn flush(&mut self) -> Result<(), Self::Error> {
|
||||||
where
|
Ok(())
|
||||||
Self: 'a;
|
|
||||||
|
|
||||||
fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> {
|
|
||||||
futures_util::future::ready(Ok(()))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,30 +379,18 @@ mod io_impls {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<M: RawMutex, const N: usize> embedded_io::asynch::Read for &Pipe<M, N> {
|
impl<M: RawMutex, const N: usize> embedded_io::asynch::Read for &Pipe<M, N> {
|
||||||
type ReadFuture<'a> = impl Future<Output = Result<usize, Self::Error>> + 'a
|
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
|
||||||
where
|
Ok(Pipe::read(self, buf).await)
|
||||||
Self: 'a;
|
|
||||||
|
|
||||||
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> {
|
|
||||||
Pipe::read(self, buf).map(Ok)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<M: RawMutex, const N: usize> embedded_io::asynch::Write for &Pipe<M, N> {
|
impl<M: RawMutex, const N: usize> embedded_io::asynch::Write for &Pipe<M, N> {
|
||||||
type WriteFuture<'a> = impl Future<Output = Result<usize, Self::Error>> + 'a
|
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
|
||||||
where
|
Ok(Pipe::write(self, buf).await)
|
||||||
Self: 'a;
|
|
||||||
|
|
||||||
fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> {
|
|
||||||
Pipe::write(self, buf).map(Ok)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a
|
async fn flush(&mut self) -> Result<(), Self::Error> {
|
||||||
where
|
Ok(())
|
||||||
Self: 'a;
|
|
||||||
|
|
||||||
fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> {
|
|
||||||
futures_util::future::ready(Ok(()))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,12 +399,8 @@ mod io_impls {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<M: RawMutex, const N: usize> embedded_io::asynch::Read for Reader<'_, M, N> {
|
impl<M: RawMutex, const N: usize> embedded_io::asynch::Read for Reader<'_, M, N> {
|
||||||
type ReadFuture<'a> = impl Future<Output = Result<usize, Self::Error>> + 'a
|
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
|
||||||
where
|
Ok(Reader::read(self, buf).await)
|
||||||
Self: 'a;
|
|
||||||
|
|
||||||
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> {
|
|
||||||
Reader::read(self, buf).map(Ok)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,20 +409,12 @@ mod io_impls {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<M: RawMutex, const N: usize> embedded_io::asynch::Write for Writer<'_, M, N> {
|
impl<M: RawMutex, const N: usize> embedded_io::asynch::Write for Writer<'_, M, N> {
|
||||||
type WriteFuture<'a> = impl Future<Output = Result<usize, Self::Error>> + 'a
|
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
|
||||||
where
|
Ok(Writer::write(self, buf).await)
|
||||||
Self: 'a;
|
|
||||||
|
|
||||||
fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> {
|
|
||||||
Writer::write(self, buf).map(Ok)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a
|
async fn flush(&mut self) -> Result<(), Self::Error> {
|
||||||
where
|
Ok(())
|
||||||
Self: 'a;
|
|
||||||
|
|
||||||
fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> {
|
|
||||||
futures_util::future::ready(Ok(()))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,26 +33,18 @@ mod eh1 {
|
|||||||
|
|
||||||
#[cfg(all(feature = "unstable-traits", feature = "nightly"))]
|
#[cfg(all(feature = "unstable-traits", feature = "nightly"))]
|
||||||
mod eha {
|
mod eha {
|
||||||
use core::future::Future;
|
|
||||||
|
|
||||||
use futures_util::FutureExt;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::Timer;
|
use crate::Timer;
|
||||||
|
|
||||||
impl embedded_hal_async::delay::DelayUs for Delay {
|
impl embedded_hal_async::delay::DelayUs for Delay {
|
||||||
type Error = core::convert::Infallible;
|
type Error = core::convert::Infallible;
|
||||||
|
|
||||||
type DelayUsFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
|
async fn delay_us(&mut self, micros: u32) -> Result<(), Self::Error> {
|
||||||
|
Ok(Timer::after(Duration::from_micros(micros as _)).await)
|
||||||
fn delay_us(&mut self, micros: u32) -> Self::DelayUsFuture<'_> {
|
|
||||||
Timer::after(Duration::from_micros(micros as _)).map(Ok)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type DelayMsFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
|
async fn delay_ms(&mut self, millis: u32) -> Result<(), Self::Error> {
|
||||||
|
Ok(Timer::after(Duration::from_millis(millis as _)).await)
|
||||||
fn delay_ms(&mut self, millis: u32) -> Self::DelayMsFuture<'_> {
|
|
||||||
Timer::after(Duration::from_millis(millis as _)).map(Ok)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#![cfg_attr(not(any(feature = "std", feature = "wasm", test)), no_std)]
|
#![cfg_attr(not(any(feature = "std", feature = "wasm", test)), no_std)]
|
||||||
#![cfg_attr(feature = "nightly", feature(type_alias_impl_trait))]
|
#![cfg_attr(feature = "nightly", feature(async_fn_in_trait))]
|
||||||
|
#![cfg_attr(feature = "nightly", allow(incomplete_features))]
|
||||||
#![doc = include_str!("../README.md")]
|
#![doc = include_str!("../README.md")]
|
||||||
#![allow(clippy::new_without_default)]
|
#![allow(clippy::new_without_default)]
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
|
@ -184,7 +184,7 @@ pub trait Bus {
|
|||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
/// * [`Unsupported`](crate::driver::Unsupported) - This UsbBus implementation doesn't support
|
/// * [`Unsupported`](crate::Unsupported) - This UsbBus implementation doesn't support
|
||||||
/// simulating a disconnect or it has not been enabled at creation time.
|
/// simulating a disconnect or it has not been enabled at creation time.
|
||||||
fn force_reset(&mut self) -> Result<(), Unsupported> {
|
fn force_reset(&mut self) -> Result<(), Unsupported> {
|
||||||
Err(Unsupported)
|
Err(Unsupported)
|
||||||
@ -194,7 +194,7 @@ pub trait Bus {
|
|||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
/// * [`Unsupported`](crate::driver::Unsupported) - This UsbBus implementation doesn't support
|
/// * [`Unsupported`](crate::Unsupported) - This UsbBus implementation doesn't support
|
||||||
/// remote wakeup or it has not been enabled at creation time.
|
/// remote wakeup or it has not been enabled at creation time.
|
||||||
async fn remote_wakeup(&mut self) -> Result<(), Unsupported>;
|
async fn remote_wakeup(&mut self) -> Result<(), Unsupported>;
|
||||||
}
|
}
|
||||||
@ -220,7 +220,7 @@ pub trait ControlPipe {
|
|||||||
fn max_packet_size(&self) -> usize;
|
fn max_packet_size(&self) -> usize;
|
||||||
|
|
||||||
/// Reads a single setup packet from the endpoint.
|
/// Reads a single setup packet from the endpoint.
|
||||||
async fn setup<'a>(&'a mut self) -> [u8; 8];
|
async fn setup(&mut self) -> [u8; 8];
|
||||||
|
|
||||||
/// Reads a DATA OUT packet into `buf` in response to a control write request.
|
/// Reads a DATA OUT packet into `buf` in response to a control write request.
|
||||||
///
|
///
|
||||||
|
@ -299,7 +299,7 @@ impl<'d, D: Driver<'d>, const N: usize> HidReader<'d, D, N> {
|
|||||||
/// **Note:** If `N` > the maximum packet size of the endpoint (i.e. output
|
/// **Note:** If `N` > the maximum packet size of the endpoint (i.e. output
|
||||||
/// reports may be split across multiple packets) and this method's future
|
/// reports may be split across multiple packets) and this method's future
|
||||||
/// is dropped after some packets have been read, the next call to `read()`
|
/// is dropped after some packets have been read, the next call to `read()`
|
||||||
/// will return a [`ReadError::SyncError()`]. The range in the sync error
|
/// will return a [`ReadError::Sync`]. The range in the sync error
|
||||||
/// indicates the portion `buf` that was filled by the current call to
|
/// indicates the portion `buf` that was filled by the current call to
|
||||||
/// `read()`. If the dropped future used the same `buf`, then `buf` will
|
/// `read()`. If the dropped future used the same `buf`, then `buf` will
|
||||||
/// contain the full report.
|
/// contain the full report.
|
||||||
|
Loading…
Reference in New Issue
Block a user