Skip to content

Commit 5cfbff9

Browse files
committed
io: use clippy to ensure that methods are forwarded in adapters
1 parent bc825d0 commit 5cfbff9

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> {
@@ -10,6 +14,10 @@ impl<T: ?Sized + Read> Read for Box<T> {
1014
}
1115

1216
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
17+
#[deny(
18+
clippy::missing_trait_methods,
19+
reason = "Methods should be forwarded to the underlying type"
20+
)]
1321
impl<T: ?Sized + BufRead> BufRead for Box<T> {
1422
#[inline]
1523
async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> {
@@ -23,6 +31,10 @@ impl<T: ?Sized + BufRead> BufRead for Box<T> {
2331
}
2432

2533
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
34+
#[deny(
35+
clippy::missing_trait_methods,
36+
reason = "Methods should be forwarded to the underlying type"
37+
)]
2638
impl<T: ?Sized + Write> Write for Box<T> {
2739
#[inline]
2840
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
@@ -36,6 +48,10 @@ impl<T: ?Sized + Write> Write for Box<T> {
3648
}
3749

3850
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
51+
#[deny(
52+
clippy::missing_trait_methods,
53+
reason = "Methods should be forwarded to the underlying type"
54+
)]
3955
impl<T: ?Sized + Seek> Seek for Box<T> {
4056
#[inline]
4157
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
@@ -170,6 +170,10 @@ pub trait Seek: ErrorType {
170170
}
171171
}
172172

173+
#[deny(
174+
clippy::missing_trait_methods,
175+
reason = "Methods should be forwarded to the underlying type"
176+
)]
173177
impl<T: ?Sized + Read> Read for &mut T {
174178
#[inline]
175179
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
@@ -182,6 +186,10 @@ impl<T: ?Sized + Read> Read for &mut T {
182186
}
183187
}
184188

189+
#[deny(
190+
clippy::missing_trait_methods,
191+
reason = "Methods should be forwarded to the underlying type"
192+
)]
185193
impl<T: ?Sized + BufRead> BufRead for &mut T {
186194
#[inline]
187195
async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> {
@@ -194,6 +202,10 @@ impl<T: ?Sized + BufRead> BufRead for &mut T {
194202
}
195203
}
196204

205+
#[deny(
206+
clippy::missing_trait_methods,
207+
reason = "Methods should be forwarded to the underlying type"
208+
)]
197209
impl<T: ?Sized + Write> Write for &mut T {
198210
#[inline]
199211
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
@@ -211,6 +223,10 @@ impl<T: ?Sized + Write> Write for &mut T {
211223
}
212224
}
213225

226+
#[deny(
227+
clippy::missing_trait_methods,
228+
reason = "Methods should be forwarded to the underlying type"
229+
)]
214230
impl<T: ?Sized + Seek> Seek for &mut T {
215231
#[inline]
216232
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> {
@@ -15,6 +23,10 @@ impl<T: ?Sized + Read> Read for Box<T> {
1523
}
1624

1725
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
26+
#[deny(
27+
clippy::missing_trait_methods,
28+
reason = "Methods should be forwarded to the underlying type"
29+
)]
1830
impl<T: ?Sized + BufRead> BufRead for Box<T> {
1931
fn fill_buf(&mut self) -> Result<&[u8], Self::Error> {
2032
T::fill_buf(self)
@@ -26,6 +38,10 @@ impl<T: ?Sized + BufRead> BufRead for Box<T> {
2638
}
2739

2840
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
41+
#[deny(
42+
clippy::missing_trait_methods,
43+
reason = "Methods should be forwarded to the underlying type"
44+
)]
2945
impl<T: ?Sized + Write> Write for Box<T> {
3046
#[inline]
3147
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
@@ -39,6 +55,10 @@ impl<T: ?Sized + Write> Write for Box<T> {
3955
}
4056

4157
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
58+
#[deny(
59+
clippy::missing_trait_methods,
60+
reason = "Methods should be forwarded to the underlying type"
61+
)]
4262
impl<T: ?Sized + Seek> Seek for Box<T> {
4363
#[inline]
4464
fn seek(&mut self, pos: crate::SeekFrom) -> Result<u64, Self::Error> {
@@ -47,6 +67,10 @@ impl<T: ?Sized + Seek> Seek for Box<T> {
4767
}
4868

4969
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
70+
#[deny(
71+
clippy::missing_trait_methods,
72+
reason = "Methods should be forwarded to the underlying type"
73+
)]
5074
impl<T: ?Sized + ReadReady> ReadReady for Box<T> {
5175
#[inline]
5276
fn read_ready(&mut self) -> Result<bool, Self::Error> {
@@ -55,6 +79,10 @@ impl<T: ?Sized + ReadReady> ReadReady for Box<T> {
5579
}
5680

5781
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
82+
#[deny(
83+
clippy::missing_trait_methods,
84+
reason = "Methods should be forwarded to the underlying type"
85+
)]
5886
impl<T: ?Sized + WriteReady> WriteReady for Box<T> {
5987
#[inline]
6088
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: Write {
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)