Skip to content

Commit 0539497

Browse files
committed
io: use clippy to ensure that methods are forwarded in adapters
1 parent c4c1077 commit 0539497

File tree

5 files changed

+105
-0
lines changed

5 files changed

+105
-0
lines changed

embedded-io-adapters/src/std.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ impl<T: ?Sized> embedded_io::ErrorType for FromStd<T> {
3636
type Error = std::io::Error;
3737
}
3838

39+
#[deny(
40+
clippy::missing_trait_methods,
41+
reason = "Methods should be forwarded to the underlying type"
42+
)]
3943
impl<T: std::io::Read + ?Sized> embedded_io::Read for FromStd<T> {
4044
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
4145
self.inner.read(buf)
@@ -55,6 +59,10 @@ impl<T: std::io::Read + ?Sized> embedded_io::Read for FromStd<T> {
5559
}
5660
}
5761

62+
#[deny(
63+
clippy::missing_trait_methods,
64+
reason = "Methods should be forwarded to the underlying type"
65+
)]
5866
impl<T: std::io::BufRead + ?Sized> embedded_io::BufRead for FromStd<T> {
5967
fn fill_buf(&mut self) -> Result<&[u8], Self::Error> {
6068
self.inner.fill_buf()
@@ -65,6 +73,10 @@ impl<T: std::io::BufRead + ?Sized> embedded_io::BufRead for FromStd<T> {
6573
}
6674
}
6775

76+
#[deny(
77+
clippy::missing_trait_methods,
78+
reason = "Methods should be forwarded to the underlying type"
79+
)]
6880
impl<T: std::io::Write + ?Sized> embedded_io::Write for FromStd<T> {
6981
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
7082
match self.inner.write(buf) {
@@ -90,6 +102,10 @@ impl<T: std::io::Write + ?Sized> embedded_io::Write for FromStd<T> {
90102
}
91103
}
92104

105+
#[deny(
106+
clippy::missing_trait_methods,
107+
reason = "Methods should be forwarded to the underlying type"
108+
)]
93109
impl<T: std::io::Seek + ?Sized> embedded_io::Seek for FromStd<T> {
94110
fn seek(&mut self, pos: embedded_io::SeekFrom) -> Result<u64, Self::Error> {
95111
self.inner.seek(pos.into())

embedded-io-async/src/impls/boxx.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ use crate::{BufRead, Read, Seek, SeekFrom, Write};
22
use alloc::boxed::Box;
33

44
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
5+
#[deny(
6+
clippy::missing_trait_methods,
7+
reason = "Methods should be forwarded to the underlying type"
8+
)]
59
impl<T: ?Sized + Read> Read for Box<T> {
610
#[inline]
711
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
@@ -18,6 +22,10 @@ impl<T: ?Sized + Read> Read for Box<T> {
1822
}
1923

2024
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
25+
#[deny(
26+
clippy::missing_trait_methods,
27+
reason = "Methods should be forwarded to the underlying type"
28+
)]
2129
impl<T: ?Sized + BufRead> BufRead for Box<T> {
2230
#[inline]
2331
async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> {
@@ -31,6 +39,10 @@ impl<T: ?Sized + BufRead> BufRead for Box<T> {
3139
}
3240

3341
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
42+
#[deny(
43+
clippy::missing_trait_methods,
44+
reason = "Methods should be forwarded to the underlying type"
45+
)]
3446
impl<T: ?Sized + Write> Write for Box<T> {
3547
#[inline]
3648
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
@@ -49,6 +61,10 @@ impl<T: ?Sized + Write> Write for Box<T> {
4961
}
5062

5163
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
64+
#[deny(
65+
clippy::missing_trait_methods,
66+
reason = "Methods should be forwarded to the underlying type"
67+
)]
5268
impl<T: ?Sized + Seek> Seek for Box<T> {
5369
#[inline]
5470
async fn seek(&mut self, pos: SeekFrom) -> Result<u64, Self::Error> {

embedded-io-async/src/lib.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ pub trait Seek: ErrorType {
168168
}
169169
}
170170

171+
#[deny(
172+
clippy::missing_trait_methods,
173+
reason = "Methods should be forwarded to the underlying type"
174+
)]
171175
impl<T: ?Sized + Read> Read for &mut T {
172176
#[inline]
173177
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
@@ -180,6 +184,10 @@ impl<T: ?Sized + Read> Read for &mut T {
180184
}
181185
}
182186

187+
#[deny(
188+
clippy::missing_trait_methods,
189+
reason = "Methods should be forwarded to the underlying type"
190+
)]
183191
impl<T: ?Sized + BufRead> BufRead for &mut T {
184192
#[inline]
185193
async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> {
@@ -192,6 +200,10 @@ impl<T: ?Sized + BufRead> BufRead for &mut T {
192200
}
193201
}
194202

203+
#[deny(
204+
clippy::missing_trait_methods,
205+
reason = "Methods should be forwarded to the underlying type"
206+
)]
195207
impl<T: ?Sized + Write> Write for &mut T {
196208
#[inline]
197209
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
@@ -209,6 +221,10 @@ impl<T: ?Sized + Write> Write for &mut T {
209221
}
210222
}
211223

224+
#[deny(
225+
clippy::missing_trait_methods,
226+
reason = "Methods should be forwarded to the underlying type"
227+
)]
212228
impl<T: ?Sized + Seek> Seek for &mut T {
213229
#[inline]
214230
async fn seek(&mut self, pos: SeekFrom) -> Result<u64, Self::Error> {

embedded-io/src/impls/boxx.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@ use crate::{BufRead, ErrorType, Read, ReadReady, Seek, Write, WriteReady};
22
use alloc::boxed::Box;
33

44
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
5+
#[deny(
6+
clippy::missing_trait_methods,
7+
reason = "Methods should be forwarded to the underlying type"
8+
)]
59
impl<T: ?Sized + ErrorType> ErrorType for Box<T> {
610
type Error = T::Error;
711
}
812

913
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
14+
#[deny(
15+
clippy::missing_trait_methods,
16+
reason = "Methods should be forwarded to the underlying type"
17+
)]
1018
impl<T: ?Sized + Read> Read for Box<T> {
1119
#[inline]
1220
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
@@ -20,6 +28,10 @@ impl<T: ?Sized + Read> Read for Box<T> {
2028
}
2129

2230
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
31+
#[deny(
32+
clippy::missing_trait_methods,
33+
reason = "Methods should be forwarded to the underlying type"
34+
)]
2335
impl<T: ?Sized + BufRead> BufRead for Box<T> {
2436
fn fill_buf(&mut self) -> Result<&[u8], Self::Error> {
2537
T::fill_buf(self)
@@ -32,6 +44,10 @@ impl<T: ?Sized + BufRead> BufRead for Box<T> {
3244
}
3345

3446
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
47+
#[deny(
48+
clippy::missing_trait_methods,
49+
reason = "Methods should be forwarded to the underlying type"
50+
)]
3551
impl<T: ?Sized + Write> Write for Box<T> {
3652
#[inline]
3753
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
@@ -58,6 +74,10 @@ impl<T: ?Sized + Write> Write for Box<T> {
5874
}
5975

6076
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
77+
#[deny(
78+
clippy::missing_trait_methods,
79+
reason = "Methods should be forwarded to the underlying type"
80+
)]
6181
impl<T: ?Sized + Seek> Seek for Box<T> {
6282
#[inline]
6383
fn seek(&mut self, pos: crate::SeekFrom) -> Result<u64, Self::Error> {
@@ -81,6 +101,10 @@ impl<T: ?Sized + Seek> Seek for Box<T> {
81101
}
82102

83103
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
104+
#[deny(
105+
clippy::missing_trait_methods,
106+
reason = "Methods should be forwarded to the underlying type"
107+
)]
84108
impl<T: ?Sized + ReadReady> ReadReady for Box<T> {
85109
#[inline]
86110
fn read_ready(&mut self) -> Result<bool, Self::Error> {
@@ -89,6 +113,10 @@ impl<T: ?Sized + ReadReady> ReadReady for Box<T> {
89113
}
90114

91115
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
116+
#[deny(
117+
clippy::missing_trait_methods,
118+
reason = "Methods should be forwarded to the underlying type"
119+
)]
92120
impl<T: ?Sized + WriteReady> WriteReady for Box<T> {
93121
#[inline]
94122
fn write_ready(&mut self) -> Result<bool, Self::Error> {

embedded-io/src/lib.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,10 @@ pub trait WriteReady: ErrorType {
553553
fn write_ready(&mut self) -> Result<bool, Self::Error>;
554554
}
555555

556+
#[deny(
557+
clippy::missing_trait_methods,
558+
reason = "Methods should be forwarded to the underlying type"
559+
)]
556560
impl<T: ?Sized + Read> Read for &mut T {
557561
#[inline]
558562
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
@@ -565,6 +569,10 @@ impl<T: ?Sized + Read> Read for &mut T {
565569
}
566570
}
567571

572+
#[deny(
573+
clippy::missing_trait_methods,
574+
reason = "Methods should be forwarded to the underlying type"
575+
)]
568576
impl<T: ?Sized + BufRead> BufRead for &mut T {
569577
#[inline]
570578
fn fill_buf(&mut self) -> Result<&[u8], Self::Error> {
@@ -577,6 +585,10 @@ impl<T: ?Sized + BufRead> BufRead for &mut T {
577585
}
578586
}
579587

588+
#[deny(
589+
clippy::missing_trait_methods,
590+
reason = "Methods should be forwarded to the underlying type"
591+
)]
580592
impl<T: ?Sized + Write> Write for &mut T {
581593
#[inline]
582594
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
@@ -592,8 +604,17 @@ impl<T: ?Sized + Write> Write for &mut T {
592604
fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error> {
593605
T::write_all(self, buf)
594606
}
607+
608+
#[inline]
609+
fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> Result<(), WriteFmtError<Self::Error>> {
610+
T::write_fmt(self, fmt)
611+
}
595612
}
596613

614+
#[deny(
615+
clippy::missing_trait_methods,
616+
reason = "Methods should be forwarded to the underlying type"
617+
)]
597618
impl<T: ?Sized + Seek> Seek for &mut T {
598619
#[inline]
599620
fn seek(&mut self, pos: SeekFrom) -> Result<u64, Self::Error> {
@@ -616,13 +637,21 @@ impl<T: ?Sized + Seek> Seek for &mut T {
616637
}
617638
}
618639

640+
#[deny(
641+
clippy::missing_trait_methods,
642+
reason = "Methods should be forwarded to the underlying type"
643+
)]
619644
impl<T: ?Sized + ReadReady> ReadReady for &mut T {
620645
#[inline]
621646
fn read_ready(&mut self) -> Result<bool, Self::Error> {
622647
T::read_ready(self)
623648
}
624649
}
625650

651+
#[deny(
652+
clippy::missing_trait_methods,
653+
reason = "Methods should be forwarded to the underlying type"
654+
)]
626655
impl<T: ?Sized + WriteReady> WriteReady for &mut T {
627656
#[inline]
628657
fn write_ready(&mut self) -> Result<bool, Self::Error> {

0 commit comments

Comments
 (0)