rust-lang / futures-rs

Zero-cost asynchronous programming in Rust
https://rust-lang.github.io/futures-rs/
Apache License 2.0
5.31k stars 609 forks source link

provide a non-destructive mechanism to determine if a sink/stream are paired #2797

Closed tones111 closed 8 months ago

tones111 commented 8 months ago

The only mechanism I could find to determine if a sink and stream are paired is reunite which takes ownership of the values. The mechanism proposed here allows the caller to determine if the values are paired without mutation.

This behavior is useful in the case where a service receives messages from multiple connections and would like to send messages to the non-originating sinks. Currently there appears to be no way for the server to determine which sink is paired with the connection that originated the message.

I'm not tied to the function names and welcome any suggestions.

taiki-e commented 6 months ago

Published in 0.3.30.