Split Server::listen into two methods to hack around ICE related to default type params
Trying to default the type parameters leads to an ICE and strange type errors. I think this is just due to the experimental state of default type params and this change can be rolled back when they are fixed.
This commit is contained in:
@@ -46,11 +46,14 @@ impl Server<HttpListener> {
|
||||
|
||||
impl<L: NetworkListener<S, A>, S: NetworkStream, A: NetworkAcceptor<S>> Server<L> {
|
||||
/// Binds to a socket, and starts handling connections.
|
||||
pub fn listen<S, A, H, L>(self, handler: H) -> HttpResult<Listening<A>>
|
||||
where S: NetworkStream,
|
||||
///
|
||||
/// This method has unbound type parameters, so can be used when you want to use
|
||||
/// something other than the provided HttpStream, HttpAcceptor, and HttpListener.
|
||||
pub fn listen_network<H, S, A, L>(self, handler: H) -> HttpResult<Listening<A>>
|
||||
where H: Handler<A, S>,
|
||||
S: NetworkStream,
|
||||
A: NetworkAcceptor<S>,
|
||||
H: Handler<A, S>,
|
||||
L: NetworkListener<S, A> {
|
||||
L: NetworkListener<S, A>, {
|
||||
let mut acceptors = Vec::new();
|
||||
let mut sockets = Vec::new();
|
||||
for (ip, port) in self.pairs.move_iter() {
|
||||
@@ -76,6 +79,11 @@ impl<L: NetworkListener<S, A>, S: NetworkStream, A: NetworkAcceptor<S>> Server<L
|
||||
sockets: sockets,
|
||||
})
|
||||
}
|
||||
|
||||
/// Binds to a socket and starts handling connections.
|
||||
pub fn listen<H: Handler<HttpAcceptor, HttpStream>>(self, handler: H) -> HttpResult<Listening<HttpAcceptor>> {
|
||||
self.listen_network::<H, HttpStream, HttpAcceptor, HttpListener>(handler)
|
||||
}
|
||||
}
|
||||
|
||||
/// An iterator over incoming connections, represented as pairs of
|
||||
|
||||
Reference in New Issue
Block a user