fn wait<F, T>(&self, f: F) -> Result<T, handle::Error>
    where
        F: Fn(Event) -> Option<T>,
    {
        let start = time::Instant::now();

        loop {
            if let Some(timeout) = self.timeout.checked_sub(start.elapsed()) {
                match self.events.recv_timeout(timeout) {
                    Ok(event) => {
                        if let Some(t) = f(event) {
                            return Ok(t);
                        }
                    }
                    Err(chan::RecvTimeoutError::Disconnected) => {
                        return Err(handle::Error::Disconnected);
                    }
                    Err(chan::RecvTimeoutError::Timeout) => {
                        // Keep trying until our timeout reaches zero.
                        continue;
                    }
                }
            } else {
                return Err(handle::Error::Timeout);
            }
        }
    }
/// Subscribe to the event feed, and wait for the given function to return something,
/// or timeout if the specified amount of time has elapsed.
Subscribe to the event feed, and wait for the given function to return something,
or timeout if the specified amount of time has elapsed.
Subscribe to the event feed and wait for the given function to return something or timeout if the specified amount of time has elapsed .
fn wait<F, T>(&self, f: F) -> Result<T, handle::Error>
    where
        F: Fn(Event) -> Option<T>,
    {
        let start = time::Instant::now();
        loop {
            if let Some(timeout) = self.timeout.checked_sub(start.elapsed()) {
                match self.events.recv_timeout(timeout) {
                    Ok(event) => {
                        if let Some(t) = f(event) {
                            return Ok(t);
                        }
                    }
                    Err(chan::RecvTimeoutError::Disconnected) => {
                        return Err(handle::Error::Disconnected);
                    }
                    Err(chan::RecvTimeoutError::Timeout) => {
                        // Keep trying until our timeout reaches zero.
                        continue;
                    }
                }
            } else {
                return Err(handle::Error::Timeout);
            }
        }
    }
fn wait < F , T > ( & self , f : F ) -> Result < T , handle :: Error > where F : Fn ( Event ) -> Option < T > , { let start = time :: Instant :: now ( ) ; loop { if let Some ( timeout ) = self . timeout . checked_sub ( start . elapsed ( ) ) { match self . events . recv_timeout ( timeout ) { Ok ( event ) => { if let Some ( t ) = f ( event ) { return Ok ( t ) ; } } Err ( chan :: RecvTimeoutError :: Disconnected ) => { return Err ( handle :: Error :: Disconnected ) ; } Err ( chan :: RecvTimeoutError :: Timeout ) => { // Keep trying until our timeout reaches zero. continue ; } } } else { return Err ( handle :: Error :: Timeout ) ; } } }
Subscribe to the event feed, and wait for the given function to return something,
or timeout if the specified amount of time has elapsed.
Subscribe to the event feed and wait for the given function to return something or timeout if the specified amount of time has elapsed .
&self
f
F