bytecodealliance / bytecodealliance/wit-bindgen
Add framing for `TcpSocket`
- Dominant language
- Rust
- Stars
- 1.5k
- Forks
- 286
- Avg merge
- 6h 32m
- Merged PRs (30d)
- 19
Description
Hi, I would like to add framing to WASI TCP streams. Tokio provides this functionality with `tokio_util::codec::{FramedRead, FramedWrite}`, which relies on `tokio::io::{AsyncRead, AsyncWrite}`. Would it be possible to implement these traits for `wit_bindgen::async_support::{StreamReader, StreamWriter}` or `TcpSocket`?
I think it would look like this:
```rs
impl tokio::io::AsyncRead for wit_bindgen::async_support::StreamWriter {
fn poll_read(
self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
buf: &mut tokio::io::ReadBuf<'_>,
) -> std::task::Poll> {
...
}
}
impl tokio::io::AsyncWrite for wit_bindgen::async_support::StreamWriter {
fn poll_write(
self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
buf: &[u8],
) -> std::task::Poll> {
...
}
fn poll_flush(
self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll> {
...
}
fn poll_shutdown(
self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll> {
...
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.