mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-25 00:02:28 +00:00
Merge pull request #2394 from swanandx/ready-impl-tcp
impl ReadReady and WriteReady for tcp
This commit is contained in:
commit
3b6eaf414a
@ -547,6 +547,12 @@ mod embedded_io_impls {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d> embedded_io_async::ReadReady for TcpSocket<'d> {
|
||||
fn read_ready(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok(self.io.with(|s, _| s.may_recv()))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d> embedded_io_async::Write for TcpSocket<'d> {
|
||||
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
|
||||
self.io.write(buf).await
|
||||
@ -557,6 +563,12 @@ mod embedded_io_impls {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d> embedded_io_async::WriteReady for TcpSocket<'d> {
|
||||
fn write_ready(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok(self.io.with(|s, _| s.may_send()))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d> embedded_io_async::ErrorType for TcpReader<'d> {
|
||||
type Error = Error;
|
||||
}
|
||||
@ -567,6 +579,12 @@ mod embedded_io_impls {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d> embedded_io_async::ReadReady for TcpReader<'d> {
|
||||
fn read_ready(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok(self.io.with(|s, _| s.may_recv()))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d> embedded_io_async::ErrorType for TcpWriter<'d> {
|
||||
type Error = Error;
|
||||
}
|
||||
@ -580,6 +598,12 @@ mod embedded_io_impls {
|
||||
self.io.flush().await
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d> embedded_io_async::WriteReady for TcpWriter<'d> {
|
||||
fn write_ready(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok(self.io.with(|s, _| s.may_send()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// TCP client compatible with `embedded-nal-async` traits.
|
||||
|
Loading…
Reference in New Issue
Block a user