sync: Fix nightly feature compilation after upgrade to embedded-io 0.4.0

This commit is contained in:
Gabriel Smith 2022-11-27 16:24:20 -05:00
parent 805b885de6
commit d438d1b685
2 changed files with 20 additions and 57 deletions

View File

@ -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)]

View File

@ -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(()))
} }
} }
} }