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 #[inline(always)]
25 pub const fn new() -> Self {
26 Self
27 }
28}
29
30impl WallClock for StdWallClock {
31 /// Returns the current system wall time.
32 ///
33 /// # Returns
34 ///
35 /// The value produced by [`SystemTime::now`].
36 #[inline(always)]
37 fn now(&self) -> SystemTime {
38 SystemTime::now()
39 }
40}