| Crates.io | derive-tokio-io |
| lib.rs | derive-tokio-io |
| version | 0.1.0 |
| created_at | 2022-11-17 08:05:18.022294+00 |
| updated_at | 2022-11-17 08:05:18.022294+00 |
| description | Derive AsyncRead and AsyncWrite. |
| homepage | https://github.com/programatik29/derive-tokio-io |
| repository | https://github.com/programatik29/derive-tokio-io |
| max_upload_size | |
| id | 717046 |
| size | 13,650 |
Derive AsyncRead and AsyncWrite.
If the struct has only one field, AsyncRead and AsyncWrite are derived
for that field.
use derive_tokio_io::{AsyncRead, AsyncWrite};
use tokio::net::TcpStream;
#[derive(AsyncRead, AsyncWrite)]
struct Wrapper {
stream: TcpStream,
}
Generics are supported.
use derive_tokio_io::{AsyncRead, AsyncWrite};
#[derive(AsyncRead, AsyncWrite)]
struct Wrapper<IO> {
stream: IO,
}
If the struct has multiple fields, #[async_read] and #[async_write]
must be used once for any field.
use derive_tokio_io::{AsyncRead, AsyncWrite};
#[derive(AsyncRead, AsyncWrite)]
struct Wrapper<R, W> {
#[async_read]
reader: R,
#[async_write]
writer: W,
}
Everything works the same way for tuple structs.
use derive_tokio_io::{AsyncRead, AsyncWrite};
#[derive(AsyncRead, AsyncWrite)]
struct Wrapper<R, W>(
#[async_read]
R,
#[async_write]
W,
);
This project is licensed under the MIT license.