HS service API (and Hyper)

The API proposed in tor-hsservice/src/lib.rs anticipates that the next layer up will implement a StreamHandler trait, and that the HS service will call the user's trait. I'm not convinced that this is the best API.

I went to look at hyper, to see how we'd integrate that, since it seems like an obvious thing to want to do. hyper expects custom transports to implement hyper::server::accept::Accept which is isomorphic to an async Stream.

Our own tor_rtcompat::TcpListener has a similar API.

I suggest that:

  • There should be a high-level API, with similar stability to our current arti-client, which is suitable for operating an Onion Service.
  • That API ought to look like the one expected by hyper, not the one currently contemplated in tor-hsservice.

I'm not sure if arti-client ought to be the place where that API lives, but I think it probably should be. Perhaps TorClient ought to have a "start hidden service" method that returns an object which implements that stream-like API.

I'm also not sure if the API in tor-hsservice ought to stay the way it is. It could do: we could use an mpsc or something. But ISTM that if the primary API is going to be Stream-of-connections, there will only be one implementor of StreamHandler so the trait could be made private and used only for mocking, or avoided altogether.