-
Notifications
You must be signed in to change notification settings - Fork 99
Description
I have a AsyncRead + AsyncWrite
network stream that I want to compress, like a TcpStream
or TlsStream
.
Is there a way to wrap such stream to get a single CompressedStream
with async-compress
?
If I use tokio::io::split
and then wrap each part in e.g. DeflateEncoder
and DeflateDecoder
separately, I get two separate objects and not a single stream anymore. Besides, split
adds overhead by placing the inner stream behind a mutex. In chatmail/async-imap#112 I manually placed the stream behind a mutex to pass it into DeflateEncoder
and DeflateDecoder
, so at least I have an access to inner stream, but now I cannot have a get_ref()
and get_mut()
API on the resulting stream because it is behind a mutex internally.
What I want is some API like a compressed stream builder which gets encoder, decoder and underlying stream and constructs a single object that allows direct access to underlying stream via get_ref()
and get_mut()
. Is it impossible with async-compression
?