rd_interface/
macros.rs

1#[macro_export]
2macro_rules! impl_async_read_write {
3    ($s:ident, $f:tt) => {
4        impl ::rd_interface::AsyncRead for $s {
5            fn poll_read(
6                mut self: ::std::pin::Pin<&mut Self>,
7                cx: &mut ::std::task::Context<'_>,
8                buf: &mut ::rd_interface::ReadBuf,
9            ) -> ::std::task::Poll<::std::io::Result<()>> {
10                ::rd_interface::AsyncRead::poll_read(::std::pin::Pin::new(&mut self.$f), cx, buf)
11            }
12        }
13        impl ::rd_interface::AsyncWrite for $s {
14            fn poll_write(
15                mut self: ::std::pin::Pin<&mut Self>,
16                cx: &mut ::std::task::Context<'_>,
17                buf: &[u8],
18            ) -> ::std::task::Poll<::std::io::Result<usize>> {
19                ::rd_interface::AsyncWrite::poll_write(::std::pin::Pin::new(&mut self.$f), cx, buf)
20            }
21
22            fn poll_flush(
23                mut self: ::std::pin::Pin<&mut Self>,
24                cx: &mut ::std::task::Context<'_>,
25            ) -> ::std::task::Poll<::std::io::Result<()>> {
26                ::rd_interface::AsyncWrite::poll_flush(::std::pin::Pin::new(&mut self.$f), cx)
27            }
28
29            fn poll_shutdown(
30                mut self: ::std::pin::Pin<&mut Self>,
31                cx: &mut ::std::task::Context<'_>,
32            ) -> ::std::task::Poll<::std::io::Result<()>> {
33                ::rd_interface::AsyncWrite::poll_shutdown(::std::pin::Pin::new(&mut self.$f), cx)
34            }
35        }
36    };
37}