Skip to main content

qubit_clock/wall/
std_wall_clock.rs

1// =============================================================================
2//    Copyright (c) 2025 - 2026 Haixing Hu.
3//
4//    SPDX-License-Identifier: Apache-2.0
5//
6//    Licensed under the Apache License, Version 2.0.
7// =============================================================================
8//! Defines the standard system wall clock.
9
10use crate::WallClock;
11use std::time::SystemTime;
12
13/// A zero-sized wall clock backed by [`SystemTime::now`].
14#[derive(Debug, Clone, Copy, Default)]
15pub struct StdWallClock;
16
17impl StdWallClock {
18    /// Creates a standard system wall clock.
19    ///
20    /// # Returns
21    ///
22    /// A zero-sized wall clock backed by [`SystemTime::now`].
23    #[must_use]
24    pub const fn new() -> Self {
25        Self
26    }
27}
28
29impl WallClock for StdWallClock {
30    /// Returns the current system wall time.
31    ///
32    /// # Returns
33    ///
34    /// The value produced by [`SystemTime::now`].
35    fn now(&self) -> SystemTime {
36        SystemTime::now()
37    }
38}