internal docs

This commit is contained in:
Rob Ede 2021-11-30 01:07:40 +00:00
parent bd5d971dde
commit e530225520
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
1 changed files with 9 additions and 8 deletions

View File

@ -78,14 +78,14 @@ impl<R: Host> Service<ConnectInfo<R>> for ConnectorService {
} }
} }
/// Helper enum to generic over futures of resolve and connect steps. /// Chains futures of resolve and connect steps.
pub(crate) enum ConnectFut<R: Host> { pub(crate) enum ConnectFut<R: Host> {
Resolve(<ResolverService as Service<ConnectInfo<R>>>::Future), Resolve(<ResolverService as Service<ConnectInfo<R>>>::Future),
Connect(<TcpConnectorService as Service<ConnectInfo<R>>>::Future), Connect(<TcpConnectorService as Service<ConnectInfo<R>>>::Future),
} }
/// Helper enum to contain the future output of `ConnectFuture`. /// Container for the intermediate states of [`ConnectFut`].
pub(crate) enum ConnectOutput<R: Host> { pub(crate) enum ConnectFutState<R: Host> {
Resolved(ConnectInfo<R>), Resolved(ConnectInfo<R>),
Connected(Connection<R, TcpStream>), Connected(Connection<R, TcpStream>),
} }
@ -94,13 +94,14 @@ impl<R: Host> ConnectFut<R> {
fn poll_connect( fn poll_connect(
&mut self, &mut self,
cx: &mut Context<'_>, cx: &mut Context<'_>,
) -> Poll<Result<ConnectOutput<R>, ConnectError>> { ) -> Poll<Result<ConnectFutState<R>, ConnectError>> {
match self { match self {
ConnectFut::Resolve(ref mut fut) => { ConnectFut::Resolve(ref mut fut) => {
Pin::new(fut).poll(cx).map_ok(ConnectOutput::Resolved) Pin::new(fut).poll(cx).map_ok(ConnectFutState::Resolved)
} }
ConnectFut::Connect(ref mut fut) => { ConnectFut::Connect(ref mut fut) => {
Pin::new(fut).poll(cx).map_ok(ConnectOutput::Connected) Pin::new(fut).poll(cx).map_ok(ConnectFutState::Connected)
} }
} }
} }
@ -117,10 +118,10 @@ impl<R: Host> Future for ConnectServiceResponse<R> {
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
loop { loop {
match ready!(self.fut.poll_connect(cx))? { match ready!(self.fut.poll_connect(cx))? {
ConnectOutput::Resolved(res) => { ConnectFutState::Resolved(res) => {
self.fut = ConnectFut::Connect(self.tcp.call(res)); self.fut = ConnectFut::Connect(self.tcp.call(res));
} }
ConnectOutput::Connected(res) => return Poll::Ready(Ok(res)), ConnectFutState::Connected(res) => return Poll::Ready(Ok(res)),
} }
} }
} }