Skip to content

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

Open
@Ruben2424

Description

@Ruben2424

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.

h3/h3-quinn/src/lib.rs

Lines 45 to 48 in bf078de

incoming_bi: BoxStreamSync<'static, <AcceptBi<'static> as Future>::Output>,
opening_bi: Option<BoxStreamSync<'static, <OpenBi<'static> as Future>::Output>>,
incoming_uni: BoxStreamSync<'static, <AcceptUni<'static> as Future>::Output>,
opening_uni: Option<BoxStreamSync<'static, <OpenUni<'static> as Future>::Output>>,

What do you think, is it worth the time?

With a little digging and found this comment.
#3 (comment)

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-traitArea: quic trait abstractionB-rfcBlocked: request for comments. Needs more discussion.C-performanceCategory: performance. This is making existing behavior go faster.C-refactorCategory: refactor. This would improve the clarity of internal code.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions