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

substreams: Allow substreams to close without consuming self #331

Open
lexnv opened this issue Feb 25, 2025 · 0 comments
Open

substreams: Allow substreams to close without consuming self #331

lexnv opened this issue Feb 25, 2025 · 0 comments

Comments

@lexnv
Copy link
Collaborator

lexnv commented Feb 25, 2025

The current implementation consumes self when calling the close method on the substream.
After the close is called, the substream's end user should no longer write data into it.
This is a bit restrictive because the substream can be drained/read after the close call.

pub async fn close(self) {

It is entirely possible to have the following scenario:

  • Write data to the substream
  • Substream close (signals the receiver end via read bytes number = 0)
  • Read data from the substream

One such implementation is the /perf/1.0.0 protocol from rust-libp2p.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant