embassy-net: add flush to TcpSocket and TcpWriter as an inherent method

This commit is contained in:
kbleeke 2023-02-22 14:45:17 +01:00
parent f1a4db44c4
commit 035de6f3ff

View file

@ -63,6 +63,10 @@ impl<'a> TcpWriter<'a> {
pub async fn write(&mut self, buf: &[u8]) -> Result<usize, Error> {
self.io.write(buf).await
}
pub async fn flush(&mut self) -> Result<(), Error> {
self.io.flush().await
}
}
impl<'a> TcpSocket<'a> {
@ -146,6 +150,10 @@ impl<'a> TcpSocket<'a> {
self.io.write(buf).await
}
pub async fn flush(&mut self) -> Result<(), Error> {
self.io.flush().await
}
pub fn set_timeout(&mut self, duration: Option<Duration>) {
self.io.with_mut(|s, _| s.set_timeout(duration))
}