Repository navigation
Offer a Peek interface over Upgraded connections #4144
Description
Activity
- addedC-featureCategory: feature. This is adding a new feature.Category: feature. This is adding a new feature.
on Aug 7, 2026 Ideally such a trait would exist in hyper-util first. But if I understand your concern, you don't want a BufReader helper, you want to access the internaly buffer that Upgraded already has. I'm not sure I'd want to have that in hyper proper to start...
Ideally such a trait would exist in hyper-util first. But if I understand your concern, you don't want a BufReader helper, you want to access the internaly buffer that Upgraded already has. I'm not sure I'd want to have that in hyper proper to start...
If I understand you, applications should double buffer even though the internal buffer is there in memory?
While that does sound like the end result to what I said, it comes from a different place of review:
- Conservative to new traits being added directly in hyper, preferring to only have what is directly needed, or at least letting it bake in hyper-util first. (Does it affect potential io-uring support that we want?, etc)
- Not exposing internal details, like that there is a buffer inside an object.
It seems to me that
Peek(namedAsyncBufReadin tokio land) are well explored in the async/IO ecosystem in Rust, including, wrt to io-uring backends.If exposing the internal details of the buffer of
Upgradedlooks dangerous, we can always consider a mechanism where you forward the internal detail to a public type that is returnedBufferedUpgradedand you can decide at any point in time to remove internal buffers and you can simply slap aBufReaderonUpgradedand be done with it. That being said, changing such internal details can always happen over major version APIs breakages to avoid having sophisticated backward compatibility techniques and API guarantees.Let me know which solution as a maintainer you prefer and I will see what I can do (or what I should do on my end to get the end result I need).
- addedA-rtArea: runtime traits/utilsArea: runtime traits/utilsS-waiting-on-reviewStatus: waiting on review.Status: waiting on review.
on Aug 17, 2026 I think so far, I don't want to add and maintain such a trait to hyper directly. So, I'd postpone adding this without more input and need from others. I'll convert this to a discussion in the meantime.
- locked and limited conversation to collaborators
on Aug 17, 2026
Is your feature request related to a problem? Please describe.
I'm implementing some code that tries to detect whether the contents of a hyper upgraded connection can be handled or should be forwarded, for this, I need to peek 4KB and decide. Even though
Readseems to be more of anBufRead, hyper do not expose any peeking methods on its usual APIs, so I would need to implement my own buffering, ending up with double buffers.Describe the solution you'd like
Peektrait, implement it forRewind<T>Upgraded,H2UpgradedAsyncReadBuffor tokio.Describe alternatives you've considered
Additional context
I have some prototype of this feature modulo the tests, the only controversial aspect is, this is my
Peektrait:If you are interested, I can try to finish my tests and PR this up.