Skip to content

Commit d75daf9

Browse files
committed
feat(async-io): make async Write::flush a required method
1 parent c5a45ae commit d75daf9

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ impl Write for &mut [u8] {
2525
Ok(amt)
2626
}
2727

28+
#[inline]
29+
async fn flush(&mut self) -> Result<(), Self::Error> {
30+
Ok(())
31+
}
32+
2833
#[inline]
2934
async fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error> {
3035
if self.len() < buf.len() {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ impl Write for Vec<u8> {
1010
Ok(buf.len())
1111
}
1212

13+
#[inline]
14+
async fn flush(&mut self) -> Result<(), Self::Error> {
15+
Ok(())
16+
}
17+
1318
#[inline]
1419
async fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error> {
1520
self.write(buf).await?;

embedded-io-async/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,7 @@ pub trait Write: ErrorType {
127127
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>;
128128

129129
/// Flush this output stream, ensuring that all intermediately buffered contents reach their destination.
130-
async fn flush(&mut self) -> Result<(), Self::Error> {
131-
Ok(())
132-
}
130+
async fn flush(&mut self) -> Result<(), Self::Error>;
133131

134132
/// Write an entire buffer into this writer.
135133
///

0 commit comments

Comments
 (0)