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 std::time::SystemTime;
11
12use crate::WallClock;
13
14/// A zero-sized wall clock backed by [`SystemTime::now`].
15#[derive(Debug, Clone, Copy, Default)]
16pub struct StdWallClock;
17
18impl StdWallClock {
19 /// Creates a standard system wall clock.
20 ///
21 /// # Returns
22 ///
23 /// A zero-sized wall clock backed by [`SystemTime::now`].
24 #[must_use]
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 fn now(&self) -> SystemTime {
37 SystemTime::now()
38 }
39}