Skip to content

Instantly share code, notes, and snippets.

@luser

luser/idle.rs

Created Apr 29, 2020
Embed
What would you like to do?
idle_timeout_reset
/// Create a `Future` that will resolve after `idle_period` has elapsed, along with an `IdleReset` that can be used to reset the time period or cancel the timeout.
///
/// This can be used to trigger an event that should happen after a period of inactivity. Activity in this situation is indicated by calling
/// `idle_reset` on the returned `IdleReset`. The timeout can be cancelled by calling `cancel` on the `IdleReset`.
///
/// Returns a tuple of (`IdleReset`, `Future`)
pub fn idle_timeout_reset(
idle_period: Duration,
) -> (IdleReset, impl Future<Output = bool> + Send + 'static) {
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment