matchbox icon indicating copy to clipboard operation
matchbox copied to clipboard

Implement `AsyncWrite` and `AsyncRead` for `WebRtcChannel`

Open th4s opened this issue 1 year ago • 1 comments

My understanding is that currently WebRtcChannel supports sync but non-blocking API. It would be cool to have full AsyncRead and AsyncWrite support. It is already possible to take a channel from the socket with WebRtcSocket::take_channel.

What about having a

impl WebRtcChannel {
    pub fn into_async_raw(self) -> impl AsyncRead + AsyncWrite {
        // ...
    }
}

Is something like this possible? The UnboundedSender/UnboundedReceiver already implement Sink/Stream for (PeerId, Box<[u8]>) which could be leveraged for such an implementation.

th4s avatar Jul 02 '24 11:07 th4s

Since your PR didn't get linked here, its at: https://github.com/johanhelsing/matchbox/pull/461

I don't require async for my use-case, but I do need a way to do back-pressure so I can throttle updates when the network can't keep up. I suspect the ability to do async writes would work well for this, so I am interested in this feature.

Craig-Macomber avatar Oct 18 '24 04:10 Craig-Macomber