fn poll(&mut self) -> Result<Async<Option<Self::Item>>, Self::Error> {
    if let Some(value) = self.buffer.pop_front() {
      return Ok(Async::Ready(Some(value)));
    }

//    try_ready!(self.interval.poll().map_err(|_| TGBotErrorKind::Other.into_with(|| "Interval error")));

//    let cfg = self.cfg.clone();
    let last_update = self.last_update;

    let api = self.api.clone();
    let upfut = self.updates.get_or_insert_with(|| {
      api.get_update(GetUpdates::new()
        .offset(last_update + 1)
        .timeout(TELEGRAM_LONG_POLL_TIMEOUT_SECONDS))
    });

    let _updates: Option<Vec<Update>> = match upfut.poll() {
      Ok(Async::Ready(t)) => t,
      Ok(Async::NotReady) => return Ok(Async::NotReady),
      Err(err) => {
//        try_ready!(self.error_interval.poll().map_err(|_| TGBotErrorKind::Other.into_with(|| "Interval error")));
        self.updates = None;
        // todo: do not return error, if happen error, wait and retry
        return Err(err);
      }
    };

    match _updates {
      Some(updates) => {
        for update in updates {
          self.last_update = core::cmp::max(update.id, self.last_update);
          self.buffer.push_back(update);
        }
        self.updates = None;
      }
      None => {
        self.updates = None;
        try_ready!(self.error_interval.poll().map_err(|_| TGBotErrorKind::Other.into_with(|| "Interval error")));
      }
    }

    self.poll()
  }
// todo: do not return error, if happen error, wait and retry
do not return error, if happen error, wait and retry
do not return error if happen error wait and retry
fn poll(&mut self) -> Result<Async<Option<Self::Item>>, Self::Error> {
    if let Some(value) = self.buffer.pop_front() {
      return Ok(Async::Ready(Some(value)));
    }
//    try_ready!(self.interval.poll().map_err(|_| TGBotErrorKind::Other.into_with(|| "Interval error")));
//    let cfg = self.cfg.clone();
    let last_update = self.last_update;
    let api = self.api.clone();
    let upfut = self.updates.get_or_insert_with(|| {
      api.get_update(GetUpdates::new()
        .offset(last_update + 1)
        .timeout(TELEGRAM_LONG_POLL_TIMEOUT_SECONDS))
    });
    let _updates: Option<Vec<Update>> = match upfut.poll() {
      Ok(Async::Ready(t)) => t,
      Ok(Async::NotReady) => return Ok(Async::NotReady),
      Err(err) => {
//        try_ready!(self.error_interval.poll().map_err(|_| TGBotErrorKind::Other.into_with(|| "Interval error")));
        self.updates = None;
        // todo: do not return error, if happen error, wait and retry
        return Err(err);
      }
    };
    match _updates {
      Some(updates) => {
        for update in updates {
          self.last_update = core::cmp::max(update.id, self.last_update);
          self.buffer.push_back(update);
        }
        self.updates = None;
      }
      None => {
        self.updates = None;
        try_ready!(self.error_interval.poll().map_err(|_| TGBotErrorKind::Other.into_with(|| "Interval error")));
      }
    }
    self.poll()
  }
fn poll ( & mut self ) -> Result < Async < Option < Self :: Item > > , Self :: Error > { if let Some ( value ) = self . buffer . pop_front ( ) { return Ok ( Async :: Ready ( Some ( value ) ) ) ; } //    try_ready!(self.interval.poll().map_err(|_| TGBotErrorKind::Other.into_with(|| "Interval error"))); //    let cfg = self.cfg.clone(); let last_update = self . last_update ; let api = self . api . clone ( ) ; let upfut = self . updates . get_or_insert_with ( | | { api . get_update ( GetUpdates :: new ( ) . offset ( last_update + 1 ) . timeout ( TELEGRAM_LONG_POLL_TIMEOUT_SECONDS ) ) } ) ; let _updates : Option < Vec < Update > > = match upfut . poll ( ) { Ok ( Async :: Ready ( t ) ) => t , Ok ( Async :: NotReady ) => return Ok ( Async :: NotReady ) , Err ( err ) => { //        try_ready!(self.error_interval.poll().map_err(|_| TGBotErrorKind::Other.into_with(|| "Interval error"))); self . updates = None ; // todo: do not return error, if happen error, wait and retry return Err ( err ) ; } } ; match _updates { Some ( updates ) => { for update in updates { self . last_update = core :: cmp :: max ( update . id , self . last_update ) ; self . buffer . push_back ( update ) ; } self . updates = None ; } None => { self . updates = None ; try_ready ! ( self error_interval poll ( ) map_err ( TGBotErrorKind Other into_with ( " " ) ) ) ; } } self . poll ( ) }
todo: do not return error, if happen error, wait and retry
todo : do not return error if happen error wait and retry
&mut self
&mut self