fn poll_connected(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Error>> {
        loop {
            self.state = match self.state {
                // When disconnected, start connecting.
                //
                // If we're recovering from a previous failure, we retain the
                // backoff in case this connection attempt fails.
                State::Disconnected { ref mut backoff } => {
                    tracing::trace!("connecting");
                    ready!(self.resolve.poll_ready(cx).map_err(Into::into))?;
                    let future = self.resolve.resolve(self.target.clone());
                    let backoff = backoff.take();
                    State::Connecting { future, backoff }
                }

                State::Connecting {
                    ref mut future,
                    ref mut backoff,
                } => match ready!(future.poll_unpin(cx)) {
                    Ok(resolution) => {
                        tracing::trace!("Connected");
                        State::Connected {
                            resolution,
                            is_initial: true,
                        }
                    }
                    Err(e) => State::Recover {
                        error: Some(e.into()),
                        backoff: backoff.take(),
                    },
                },

                State::Connected { .. } => return Poll::Ready(Ok(())),

                // If any stage failed, try to recover. If the error is
                // recoverable, start (or continue) backing off...
                State::Recover {
                    ref mut error,
                    ref mut backoff,
                } => {
                    let err = error.take().expect("illegal state");
                    tracing::debug!(%err, "recovering");
                    let new_backoff = self.recover.recover(err)?;
                    State::Backoff(backoff.take().or(Some(new_backoff)))
                }

                State::Backoff(ref mut backoff) => {
                    let more = ready!(backoff.as_mut().expect("illegal state").poll_next_unpin(cx));
                    let backoff = if more.is_some() { backoff.take() } else { None };
                    tracing::trace!("disconnected");
                    State::Disconnected { backoff }
                }
            };
        }
    }
/// Drives the state forward until its connected.
Drives the state forward until its connected.
Drives the state forward until its connected .
fn poll_connected(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Error>> {
        loop {
            self.state = match self.state {
                // When disconnected, start connecting.
                //
                // If we're recovering from a previous failure, we retain the
                // backoff in case this connection attempt fails.
                State::Disconnected { ref mut backoff } => {
                    tracing::trace!("connecting");
                    ready!(self.resolve.poll_ready(cx).map_err(Into::into))?;
                    let future = self.resolve.resolve(self.target.clone());
                    let backoff = backoff.take();
                    State::Connecting { future, backoff }
                }
                State::Connecting {
                    ref mut future,
                    ref mut backoff,
                } => match ready!(future.poll_unpin(cx)) {
                    Ok(resolution) => {
                        tracing::trace!("Connected");
                        State::Connected {
                            resolution,
                            is_initial: true,
                        }
                    }
                    Err(e) => State::Recover {
                        error: Some(e.into()),
                        backoff: backoff.take(),
                    },
                },
                State::Connected { .. } => return Poll::Ready(Ok(())),
                // If any stage failed, try to recover. If the error is
                // recoverable, start (or continue) backing off...
                State::Recover {
                    ref mut error,
                    ref mut backoff,
                } => {
                    let err = error.take().expect("illegal state");
                    tracing::debug!(%err, "recovering");
                    let new_backoff = self.recover.recover(err)?;
                    State::Backoff(backoff.take().or(Some(new_backoff)))
                }
                State::Backoff(ref mut backoff) => {
                    let more = ready!(backoff.as_mut().expect("illegal state").poll_next_unpin(cx));
                    let backoff = if more.is_some() { backoff.take() } else { None };
                    tracing::trace!("disconnected");
                    State::Disconnected { backoff }
                }
            };
        }
    }
fn poll_connected ( & mut self , cx : & mut Context < ' _ > ) -> Poll < Result < ( ) , Error > > { loop { self . state = match self . state { // When disconnected, start connecting. // // If we're recovering from a previous failure, we retain the // backoff in case this connection attempt fails. State :: Disconnected { ref mut backoff } => { tracing :: trace ! ( " " ) ; ready ! ( self resolve poll_ready ( cx ) map_err ( Into into ) ) ? ; let future = self . resolve . resolve ( self . target . clone ( ) ) ; let backoff = backoff . take ( ) ; State :: Connecting { future , backoff } } State :: Connecting { ref mut future , ref mut backoff , } => match ready ! ( future poll_unpin ( cx ) ) { Ok ( resolution ) => { tracing :: trace ! ( " " ) ; State :: Connected { resolution , is_initial : true , } } Err ( e ) => State :: Recover { error : Some ( e . into ( ) ) , backoff : backoff . take ( ) , } , } , State :: Connected { .. } => return Poll :: Ready ( Ok ( ( ) ) ) , // If any stage failed, try to recover. If the error is // recoverable, start (or continue) backing off... State :: Recover { ref mut error , ref mut backoff , } => { let err = error . take ( ) . expect ( " " ) ; tracing :: debug ! ( err " " ) ; let new_backoff = self . recover . recover ( err ) ? ; State :: Backoff ( backoff . take ( ) . or ( Some ( new_backoff ) ) ) } State :: Backoff ( ref mut backoff ) => { let more = ready ! ( backoff as_mut ( ) expect ( " " ) poll_next_unpin ( cx ) ) ; let backoff = if more . is_some ( ) { backoff . take ( ) } else { None } ; tracing :: trace ! ( " " ) ; State :: Disconnected { backoff } } } ; } }
Drives the state forward until its connected.
Drives the state forward until its connected .
&mut self
cx
&mut Context<'_>
&mut self
cx
&mut Context<'_>