hyperium / hyperium/h3

Refactor quic traits `Connection` and `OpenStreams` to use `self: Pin<&mut Self>` instead of `&mut self`

Open
#298 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-trait B-rfc C-performance C-refactor
Dominant language
Rust
Stars
890
Forks
136
Avg merge
14d 20h
Merged PRs (30d)
2

Description

The current quic traits have &mut self in the function signature. For example:

    fn poll_accept_recv(
        &mut self,
        cx: &mut task::Context<'_>,
    ) -> Poll<Result<Self::RecvStream, ConnectionErrorIncoming>>;

In the original proposal some of the trait methods had self: Pin<&mut Self> instead.
https://github.com/hyperium/h3/blob/master/docs/PROPOSAL.md#connections

It would take a large refactor to chance it now, but i think it is possible for the Connection and OpenStreams trait.

This would allow quic implementations like h3-quinn to not require Boxing the streams.
https://github.com/hyperium/h3/blob/bf078de3c769d2ea7b01bf6c4829c148b9ab9935/h3-quinn/src/lib.rs#L45-L48

What do you think, is it worth the time?

With a little digging and found this comment.
https://github.com/hyperium/h3/pull/3#discussion_r464525968

This comment refes to the RecvStream trait.
The problem mentioned in the comment can be worked around for Connection and OpenStreams which only have two methods not needing Pin , which is close and opener.
Either by defining a new separate trait for close and opener or by maintaining a separate cloneable instance of OpenStreams which is not pinned.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Connection and OpenStreams trait definitions and compare their signatures with the connections section of docs/PROPOSAL.md. Read h3-quinn/src/lib.rs around the referenced stream implementation and the discussion in PR #3 to understand the pinning constraint. Done means agreeing on the trait design and completing the resulting refactor without requiring boxed streams in h3-quinn.

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
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.