Skip to content

tor-rtcompat: Simplify IncomingTcpStreams for async-std using unfold

The impl_stream macro for async-std builds an IncomingTcpStreams (and IncomingUnixStreams). This stream type stores a state object that holds the future returned from calling TcpListener::accept(). I think that this could be made simpler with futures::stream::unfold:

Creates a Stream from a seed and a closure returning a Future.

This would also help us get rid of some boxing since we would no longer need to box each future.

Although async-std is discontinued, we'll probably need to support it for awhile. We would probably also want to do this for smol as well once !2986 (merged) is merged, which uses the same approach as async-std.

This would be good for the "First Contribution" label, but should wait until smol support is merged.

Edited by opara