flareapp-core 0.2.0

The core of the Flare client: config, the client, and the worker thread that sends data.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
//! Adds a duration to an `Instant` without overflow.

use std::time::{Duration, Instant};

const MAX_WAIT: Duration = Duration::from_hours(1);

/// Returns `instant + duration`. A duration longer than one hour counts as one
/// hour, so the sum can never overflow.
pub(crate) fn later(instant: Instant, duration: Duration) -> Instant {
    instant
        .checked_add(duration.min(MAX_WAIT))
        .unwrap_or(instant)
}