Skip to content

Commit 64fb23d

Browse files
committed
io: reduce noise using module-level clippy deny
1 parent 5cfbff9 commit 64fb23d

File tree

8 files changed

+170
-224
lines changed

8 files changed

+170
-224
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#![deny(
2+
clippy::missing_trait_methods,
3+
reason = "Methods should be forwarded to the underlying type"
4+
)]
5+
6+
use embedded_io::{ReadExactError, SeekFrom};
7+
8+
use crate::{BufRead, Read, Seek, Write};
9+
10+
impl<T: ?Sized + Read> Read for &mut T {
11+
#[inline]
12+
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
13+
T::read(self, buf).await
14+
}
15+
16+
#[inline]
17+
async fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), ReadExactError<Self::Error>> {
18+
T::read_exact(self, buf).await
19+
}
20+
}
21+
22+
impl<T: ?Sized + BufRead> BufRead for &mut T {
23+
#[inline]
24+
async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> {
25+
T::fill_buf(self).await
26+
}
27+
28+
#[inline]
29+
fn consume(&mut self, amt: usize) {
30+
T::consume(self, amt);
31+
}
32+
}
33+
34+
impl<T: ?Sized + Write> Write for &mut T {
35+
#[inline]
36+
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
37+
T::write(self, buf).await
38+
}
39+
40+
#[inline]
41+
async fn flush(&mut self) -> Result<(), Self::Error> {
42+
T::flush(self).await
43+
}
44+
45+
#[inline]
46+
async fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error> {
47+
T::write_all(self, buf).await
48+
}
49+
}
50+
51+
impl<T: ?Sized + Seek> Seek for &mut T {
52+
#[inline]
53+
async fn seek(&mut self, pos: SeekFrom) -> Result<u64, Self::Error> {
54+
T::seek(self, pos).await
55+
}
56+
57+
#[inline]
58+
async fn rewind(&mut self) -> Result<(), Self::Error> {
59+
T::rewind(self).await
60+
}
61+
62+
#[inline]
63+
async fn stream_position(&mut self) -> Result<u64, Self::Error> {
64+
T::stream_position(self).await
65+
}
66+
}

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

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
#![deny(
2+
clippy::missing_trait_methods,
3+
reason = "Methods should be forwarded to the underlying type"
4+
)]
5+
16
use crate::{BufRead, Read, Seek, SeekFrom, Write};
27
use alloc::boxed::Box;
38

49
#[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-
)]
910
impl<T: ?Sized + Read> Read for Box<T> {
1011
#[inline]
1112
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
@@ -14,10 +15,6 @@ impl<T: ?Sized + Read> Read for Box<T> {
1415
}
1516

1617
#[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-
)]
2118
impl<T: ?Sized + BufRead> BufRead for Box<T> {
2219
#[inline]
2320
async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> {
@@ -31,10 +28,6 @@ impl<T: ?Sized + BufRead> BufRead for Box<T> {
3128
}
3229

3330
#[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-
)]
3831
impl<T: ?Sized + Write> Write for Box<T> {
3932
#[inline]
4033
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
@@ -48,10 +41,6 @@ impl<T: ?Sized + Write> Write for Box<T> {
4841
}
4942

5043
#[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-
)]
5544
impl<T: ?Sized + Seek> Seek for Box<T> {
5645
#[inline]
5746
async fn seek(&mut self, pos: SeekFrom) -> Result<u64, Self::Error> {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
mod blanket;
12
mod slice_mut;
23
mod slice_ref;
34

embedded-io-async/src/lib.rs

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -169,77 +169,3 @@ pub trait Seek: ErrorType {
169169
self.seek(SeekFrom::Current(0)).await
170170
}
171171
}
172-
173-
#[deny(
174-
clippy::missing_trait_methods,
175-
reason = "Methods should be forwarded to the underlying type"
176-
)]
177-
impl<T: ?Sized + Read> Read for &mut T {
178-
#[inline]
179-
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
180-
T::read(self, buf).await
181-
}
182-
183-
#[inline]
184-
async fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), ReadExactError<Self::Error>> {
185-
T::read_exact(self, buf).await
186-
}
187-
}
188-
189-
#[deny(
190-
clippy::missing_trait_methods,
191-
reason = "Methods should be forwarded to the underlying type"
192-
)]
193-
impl<T: ?Sized + BufRead> BufRead for &mut T {
194-
#[inline]
195-
async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> {
196-
T::fill_buf(self).await
197-
}
198-
199-
#[inline]
200-
fn consume(&mut self, amt: usize) {
201-
T::consume(self, amt);
202-
}
203-
}
204-
205-
#[deny(
206-
clippy::missing_trait_methods,
207-
reason = "Methods should be forwarded to the underlying type"
208-
)]
209-
impl<T: ?Sized + Write> Write for &mut T {
210-
#[inline]
211-
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
212-
T::write(self, buf).await
213-
}
214-
215-
#[inline]
216-
async fn flush(&mut self) -> Result<(), Self::Error> {
217-
T::flush(self).await
218-
}
219-
220-
#[inline]
221-
async fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error> {
222-
T::write_all(self, buf).await
223-
}
224-
}
225-
226-
#[deny(
227-
clippy::missing_trait_methods,
228-
reason = "Methods should be forwarded to the underlying type"
229-
)]
230-
impl<T: ?Sized + Seek> Seek for &mut T {
231-
#[inline]
232-
async fn seek(&mut self, pos: SeekFrom) -> Result<u64, Self::Error> {
233-
T::seek(self, pos).await
234-
}
235-
236-
#[inline]
237-
async fn rewind(&mut self) -> Result<(), Self::Error> {
238-
T::rewind(self).await
239-
}
240-
241-
#[inline]
242-
async fn stream_position(&mut self) -> Result<u64, Self::Error> {
243-
T::stream_position(self).await
244-
}
245-
}

embedded-io/src/impls/blanket.rs

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#![deny(
2+
clippy::missing_trait_methods,
3+
reason = "Methods should be forwarded to the underlying type"
4+
)]
5+
6+
use core::fmt;
7+
8+
use crate::{
9+
BufRead, Read, ReadExactError, ReadReady, Seek, SeekFrom, Write, WriteFmtError, WriteReady,
10+
};
11+
12+
impl<T: ?Sized + Read> Read for &mut T {
13+
#[inline]
14+
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
15+
T::read(self, buf)
16+
}
17+
18+
#[inline]
19+
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), ReadExactError<Self::Error>> {
20+
T::read_exact(self, buf)
21+
}
22+
}
23+
24+
impl<T: ?Sized + BufRead> BufRead for &mut T {
25+
#[inline]
26+
fn fill_buf(&mut self) -> Result<&[u8], Self::Error> {
27+
T::fill_buf(self)
28+
}
29+
30+
#[inline]
31+
fn consume(&mut self, amt: usize) {
32+
T::consume(self, amt);
33+
}
34+
}
35+
36+
impl<T: ?Sized + Write> Write for &mut T {
37+
#[inline]
38+
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
39+
T::write(self, buf)
40+
}
41+
42+
#[inline]
43+
fn flush(&mut self) -> Result<(), Self::Error> {
44+
T::flush(self)
45+
}
46+
47+
#[inline]
48+
fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error> {
49+
T::write_all(self, buf)
50+
}
51+
52+
#[inline]
53+
fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> Result<(), WriteFmtError<Self::Error>> {
54+
T::write_fmt(self, fmt)
55+
}
56+
}
57+
58+
impl<T: ?Sized + Seek> Seek for &mut T {
59+
#[inline]
60+
fn seek(&mut self, pos: SeekFrom) -> Result<u64, Self::Error> {
61+
T::seek(self, pos)
62+
}
63+
64+
#[inline]
65+
fn rewind(&mut self) -> Result<(), Self::Error> {
66+
T::rewind(self)
67+
}
68+
69+
#[inline]
70+
fn stream_position(&mut self) -> Result<u64, Self::Error> {
71+
T::stream_position(self)
72+
}
73+
74+
#[inline]
75+
fn seek_relative(&mut self, offset: i64) -> Result<(), Self::Error> {
76+
T::seek_relative(self, offset)
77+
}
78+
}
79+
80+
impl<T: ?Sized + ReadReady> ReadReady for &mut T {
81+
#[inline]
82+
fn read_ready(&mut self) -> Result<bool, Self::Error> {
83+
T::read_ready(self)
84+
}
85+
}
86+
87+
impl<T: ?Sized + WriteReady> WriteReady for &mut T {
88+
#[inline]
89+
fn write_ready(&mut self) -> Result<bool, Self::Error> {
90+
T::write_ready(self)
91+
}
92+
}

embedded-io/src/impls/boxx.rs

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1+
#![deny(
2+
clippy::missing_trait_methods,
3+
reason = "Methods should be forwarded to the underlying type"
4+
)]
5+
16
use crate::{BufRead, ErrorType, Read, ReadReady, Seek, Write, WriteReady};
27
use alloc::boxed::Box;
38

49
#[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-
)]
910
impl<T: ?Sized + ErrorType> ErrorType for Box<T> {
1011
type Error = T::Error;
1112
}
1213

1314
#[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-
)]
1815
impl<T: ?Sized + Read> Read for Box<T> {
1916
#[inline]
2017
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
@@ -23,10 +20,6 @@ impl<T: ?Sized + Read> Read for Box<T> {
2320
}
2421

2522
#[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-
)]
3023
impl<T: ?Sized + BufRead> BufRead for Box<T> {
3124
fn fill_buf(&mut self) -> Result<&[u8], Self::Error> {
3225
T::fill_buf(self)
@@ -38,10 +31,6 @@ impl<T: ?Sized + BufRead> BufRead for Box<T> {
3831
}
3932

4033
#[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-
)]
4534
impl<T: ?Sized + Write> Write for Box<T> {
4635
#[inline]
4736
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
@@ -55,10 +44,6 @@ impl<T: ?Sized + Write> Write for Box<T> {
5544
}
5645

5746
#[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-
)]
6247
impl<T: ?Sized + Seek> Seek for Box<T> {
6348
#[inline]
6449
fn seek(&mut self, pos: crate::SeekFrom) -> Result<u64, Self::Error> {
@@ -67,10 +52,6 @@ impl<T: ?Sized + Seek> Seek for Box<T> {
6752
}
6853

6954
#[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-
)]
7455
impl<T: ?Sized + ReadReady> ReadReady for Box<T> {
7556
#[inline]
7657
fn read_ready(&mut self) -> Result<bool, Self::Error> {
@@ -79,10 +60,6 @@ impl<T: ?Sized + ReadReady> ReadReady for Box<T> {
7960
}
8061

8162
#[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-
)]
8663
impl<T: ?Sized + WriteReady> WriteReady for Box<T> {
8764
#[inline]
8865
fn write_ready(&mut self) -> Result<bool, Self::Error> {

embedded-io/src/impls/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
mod blanket;
12
mod slice_mut;
23
mod slice_ref;
34

0 commit comments

Comments
 (0)