An example implementation of allowing futures::Stream
s to be stopped remotely.
This is a very simple implementation which wraps a stream with another stream that will finish when it receives a message from a sender.
let (stream, handle) = futures_stop::convert_to_stoppable(stream);
// ...
handle.stop().wait().unwrap();
// or
handle.wait().stop();