-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrapping an AsyncRead + AsyncWrite
stream
#296
Comments
The other option to fix this without changing API is to do like Then I will be able to just wrap the whole stream into |
I am going to pass through |
You can use It does use |
This works if you have plain |
cc @link2xt how about Can it solve your problem efficiently? |
In async-imap I even have just |
Can you call Or, can you pass a reference to the |
Hmmm I was mostly worried about having mismatched functionality, since But then I realized that if we consider async-compression to be a decorator that adds a layer to decompress/compress, it does make sense |
https://docs.rs/tokio/latest/tokio/io/struct.BufReader.html passes Same for |
Yeah it does seem to be a reasonable pattern. The buf reader/tls/compress/decompress can be seen as an decorator, so they should pass through everything trait that isn't decorated. |
I have a
AsyncRead + AsyncWrite
network stream that I want to compress, like aTcpStream
orTlsStream
.Is there a way to wrap such stream to get a single
CompressedStream
withasync-compress
?If I use
tokio::io::split
and then wrap each part in e.g.DeflateEncoder
andDeflateDecoder
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 async-email/async-imap#112 I manually placed the stream behind a mutex to pass it intoDeflateEncoder
andDeflateDecoder
, so at least I have an access to inner stream, but now I cannot have aget_ref()
andget_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()
andget_mut()
. Is it impossible withasync-compression
?The text was updated successfully, but these errors were encountered: