termit-ui 0.0.1

Terminal UI with GUI-like layouts
Documentation
mod color;
mod gui;
pub use self::gui::*;

use std::time::Duration;

/// calculates a wait backoff period for given idle period
fn backoff(idle: Duration) -> Duration {
    let idle = idle
        .checked_mul(1000)
        .map(|ms| ms.as_secs())
        .unwrap_or(10000);

    let min = 3;
    let max = 300;
    let time = 20000;
    let max = max - min;
    let scale = u64::max_value() / max;
    let backoff = min + (idle.saturating_mul(max) / time).saturating_mul(scale) / scale;

    Duration::from_millis(backoff)
}