Closed Hoverbear closed 9 years ago
self.listener
.accept().map_err(From::from)
.and_then(|stream_opt| stream_opt.ok_or(
Error::Io(io::Error::new(io::ErrorKind::WouldBlock,
"listener.accept() returned None"))))
.and_then(|stream| Connection::unknown(stream))
.and_then(|connection| {
scoped_debug!("new connection received: {:?}", connection);
self.connections
.insert(connection)
.map_err(|_| Error::Raft(ErrorKind::ConnectionLimitReached))
})
.and_then(|token| self.connections[token].register(event_loop, token))
.unwrap_or_else(|error| scoped_warn!("unable to accept connection: {}", error));
@james-darkfox noted this could improve.