Skip to content

Commit 202c88c

Browse files
committed
io: reduce noise using module-level clippy deny
1 parent 0539497 commit 202c88c

File tree

9 files changed

+175
-240
lines changed

9 files changed

+175
-240
lines changed

embedded-io-adapters/src/std.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
//! Adapters to/from `std::io` traits.
22
3+
#![deny(
4+
clippy::missing_trait_methods,
5+
reason = "Methods should be forwarded to the underlying type"
6+
)]
7+
38
use embedded_io::Error as _;
49

510
/// Adapter from `std::io` traits.
@@ -36,10 +41,6 @@ impl<T: ?Sized> embedded_io::ErrorType for FromStd<T> {
3641
type Error = std::io::Error;
3742
}
3843

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

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

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

105-
#[deny(
106-
clippy::missing_trait_methods,
107-
reason = "Methods should be forwarded to the underlying type"
108-
)]
10998
impl<T: std::io::Seek + ?Sized> embedded_io::Seek for FromStd<T> {
11099
fn seek(&mut self, pos: embedded_io::SeekFrom) -> Result<u64, Self::Error> {
111100
self.inner.seek(pos.into())
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> {
@@ -22,10 +23,6 @@ impl<T: ?Sized + Read> Read for Box<T> {
2223
}
2324

2425
#[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-
)]
2926
impl<T: ?Sized + BufRead> BufRead for Box<T> {
3027
#[inline]
3128
async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> {
@@ -39,10 +36,6 @@ impl<T: ?Sized + BufRead> BufRead for Box<T> {
3936
}
4037

4138
#[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-
)]
4639
impl<T: ?Sized + Write> Write for Box<T> {
4740
#[inline]
4841
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
@@ -61,10 +54,6 @@ impl<T: ?Sized + Write> Write for Box<T> {
6154
}
6255

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

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+
}

0 commit comments

Comments
 (0)