-
Notifications
You must be signed in to change notification settings - Fork 960
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
core: Remove Transport::{Dial,ListenUpgrade}
in favor of using trait objects
#3347
Comments
Drawback discussions
I've not done any measurements but I'd be very surprised if the allocations matter in the context of network connections. Even if we decide that performance is super critical here, one could argue that for fast transports like QUIC, the impact is smaller because only one allocation will happen. Additionally, If we are really keen on optimizing the performance here, we could go down a route similar to what is discussed in #2829. If the main
In |
Note that, whilst the initial idea might be very niche and not that important, I think the benefits of simplifying the |
Based on intuition, I don't think boxing has any performance impact compared to the amount of work required to establish a connection, thus I don't think it needs to be considered in this discussion. I don't have an opinion on the above (i.e. boxing or not). That said, I agree that this has priority nicetohave. |
after the TAIT feature stable, i think we can write so i think we could reserve these associated type but rewrite those handwriting futures with |
In my eyes, the associated type is the complexity that needs to go away. "impl trait in trait" would solve that maybe. However, as argued above, there really is no downside in just removing them. Someone just needs to pick it up and do it :) (I have a WIP branch I'll push.) |
It is here: #3436 |
Context
Whilst toying around with #2650 which was motivated by trying to solve the merge conflicts in #3254, I came across our
EitherFuture
type. This one exists because the trait bounds onTransport::Dial
andTransport::ListenUpgrade
force the designated type to "transpose" the output. In other words, withEither
implementingTransport
, the output ofDial
is required to beResult<Either<A, B>, ...>
instead ofEither<Result<A, ..>, Result<B, ..>>
. This makes sense but is not compatible with a general implementation ofFuture
on a type likeEither
. Thus, we need to provide our own, specialized type for this.Proposal
Should we remove the associated types
Dial
andListenUpgrade
in favor of always usingBoxFuture
?Benefits
Transport
implementationsDrawbacks
Transport
s to beSend
The text was updated successfully, but these errors were encountered: