memfaultd 1.26.1

Memfault daemon for embedded Linux systems. Observability, logging, crash reporting, and updating all in one service. Learn more at https://docs.memfault.com/
Documentation
//
// Copyright (c) Memfault, Inc.
// See License.txt for details
use std::time::{Duration, Instant};

/// A trait for measuring time.
///
/// This is mostly a way to mock std::time::Instant for testing.
pub trait TimeMeasure {
    fn now() -> Self;
    fn elapsed(&self) -> Duration;
    fn since(&self, other: &Self) -> Duration;
}

impl TimeMeasure for Instant {
    fn now() -> Self {
        Instant::now()
    }

    fn elapsed(&self) -> Duration {
        Self::now().since(self)
    }

    fn since(&self, other: &Self) -> Duration {
        Instant::duration_since(self, *other)
    }
}