macroonz-harness 0.2.0

Safe-Rust property, fuzz, fault, schedule, mutation, network, and benchmark testing with typed evidence, reduction, and replay.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! The checked difference between the two ticks of one measurement.
//!
//! A backwards pair refuses as [`ClockFailure::Regressed`] rather than saturating to zero.

use super::{ClockFailure, MeasurementTick, RecordedDuration};

pub(in crate::clock) fn elapsed(
    opened: MeasurementTick,
    closed: MeasurementTick,
) -> Result<RecordedDuration, ClockFailure> {
    let Some(nanoseconds) = closed.nanoseconds().checked_sub(opened.nanoseconds()) else {
        return Err(ClockFailure::Regressed { opened, closed });
    };
    Ok(RecordedDuration::recorded(nanoseconds))
}