core: Remove `Transport::{Dial,ListenUpgrade}` in favor of using trait objects
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.6k
- Forks
- 1.3k
- Avg merge
- 8h 47m
- Merged PRs (30d)
- 19
Description
Context
Whilst toying around with https://github.com/libp2p/rust-libp2p/issues/2650 which was motivated by trying to solve the merge conflicts in https://github.com/libp2p/rust-libp2p/pull/3254, I came across our EitherFuture type. This one exists because the trait bounds on Transport::Dial and Transport::ListenUpgrade force the designated type to "transpose" the output. In other words, with Either implementing Transport, the output of Dial is required to be Result<Either<A, B>, ...> instead of Either<Result<A, ..>, Result<B, ..>>. This makes sense but is not compatible with a general implementation of Future on a type like Either. Thus, we need to provide our own, specialized type for this.
Proposal
Should we remove the associated types Dial and ListenUpgrade in favor of always using BoxFuture?
Benefits
- Less code to maintain
- Simplified interface
- Smaller public API of
Transportimplementations
Drawbacks
- Forces all
Transports to beSend - More allocations as part of creating new network connections
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the Transport trait, its Dial and ListenUpgrade associated types, and the EitherFuture type described in the issue. Trace the affected Transport implementations and determine whether replacing those associated types with BoxFuture preserves the stated behavior and addresses the listed trade-offs; done means the proposal is implemented consistently across the public API.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- networking
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100