Unnecessary lifetime in `SignalStream<'a>` prevents moving into spawned tasks.
The SignalStream<'a>
has a lifetime that isn't actually used:
#[derive(Debug)]
pub struct SignalStream<'a> {
stream: Join<MessageStream, Option<MessageStream>>,
src_unique_name: Option<UniqueName<'static>>,
phantom: PhantomData<&'a ()>,
}
I imagine this was added to prevent the stream from outliving the proxy object. However, a Stream
already has an interface for dealing with that situation: it can return Ready(None)
from poll_next()
when it will no longer produce any value.
The lifetime now prevents moving the stream into a spawned task. As a result, all handling of signals must now happen in the same task where the connection was made. This is quite a big restriction, and it seems artificial in the case of a SignalStream
.