Skip to content
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/muxing: Redesign StreamMuxer trait #2648

Closed

Commits on Jun 15, 2022

  1. Fix StreamMuxer::Error to io::Error

    We are already enforcing that the associated type must convert to
    `io::Error`. We might as well just make all functions return an
    `io::Error` directly.
    thomaseizinger committed Jun 15, 2022
    Configuration menu
    Copy the full SHA
    aa946c2 View commit details
    Browse the repository at this point in the history
  2. Add newline before return value

    Visually separating this makes it easier to read.
    thomaseizinger committed Jun 15, 2022
    Configuration menu
    Copy the full SHA
    4c39aec View commit details
    Browse the repository at this point in the history
  3. Re-design the StreamMuxer trait

    The current `StreamMuxer` API is based around a poll-based approach
    where each substream needs to be passed by value to read/write/close
    it.
    
    The muxer itself however is not available in the end-user abstractions
    like `ConnectionHandler`. To circumvent this, the `StreamMuxerBox`
    type exists which allows a `StreamMuxer` to be cloned. Together with
    `SubstreamRef`, this allows each substream to own a reference to the
    muxer it was created with and pass itself to the muxer within
    implementations of `AsyncRead` and `AsyncWrite`. These implementations
    are convenient as they allow an end-user to simply read and write to
    the substream without holding a reference to anything else.
    
    We can achieve the same goal by changing the `StreamMuxerBox` abstraction
    to use a `SubstreamBox`. Users of `libp2p-core` can continue to
    depend on the `Substream` associated type of `StreamMuxer`.
    thomaseizinger committed Jun 15, 2022
    Configuration menu
    Copy the full SHA
    d44b0a6 View commit details
    Browse the repository at this point in the history
  4. fixup! Re-design the StreamMuxer trait

    Reduce diff.
    thomaseizinger committed Jun 15, 2022
    Configuration menu
    Copy the full SHA
    4b6144c View commit details
    Browse the repository at this point in the history
  5. fixup! Re-design the StreamMuxer trait

    Reduce diff.
    thomaseizinger committed Jun 15, 2022
    Configuration menu
    Copy the full SHA
    32bb190 View commit details
    Browse the repository at this point in the history
  6. fixup! Re-design the StreamMuxer trait

    Fix compile errors.
    thomaseizinger committed Jun 15, 2022
    Configuration menu
    Copy the full SHA
    377187c View commit details
    Browse the repository at this point in the history
  7. fixup! Re-design the StreamMuxer trait

    Fix docs error.
    thomaseizinger committed Jun 15, 2022
    Configuration menu
    Copy the full SHA
    5d628bc View commit details
    Browse the repository at this point in the history