scsys_time/
lib.rs

1/*
2    Appellation: scsys-time <library>
3    Created At: 2025.09.08:18:11:37
4    Contrib: @FL03
5*/
6//! The [`time`](self) module focuses on implementing various time-related features and utilities.
7//! It provides a generic [`Timestamp`] along with supporting traits and types to facilitate
8//! time management.
9//!
10//! Additionally, the crate defines several key traits to support time functionalities:
11//!
12//! - [`RawTimestamp`] - A marker trait denoting compatible raw timestamp types
13//! - [`Now`] - A trait for obtaining the current time
14//!
15#![allow(
16    non_snake_case,
17    clippy::module_inception,
18    clippy::missing_safety_doc,
19    clippy::needless_doctest_main,
20    clippy::upper_case_acronyms
21)]
22#![cfg_attr(not(feature = "std"), no_std)]
23#![cfg_attr(all(feature = "alloc", feature = "nightly"), feature(allocator_api))]
24#![doc(
25    html_logo_url = "https://raw.githubusercontent.com/scattered-systems/.github/main/assets/logo.png",
26    html_favicon_url = "https://raw.githubusercontent.com/scattered-systems/.github/main/assets/favicon.ico"
27)]
28
29#[cfg(feature = "alloc")]
30extern crate alloc;
31
32#[cfg(not(any(feature = "alloc", feature = "std")))]
33compile_error!(
34    "Either feature \"alloc\" or feature \"std\" must be enabled for the `time` crate to compile."
35);
36
37#[doc(inline)]
38pub use self::{
39    epoch::Epoch,
40    error::{Error, Result},
41    timestamp::Timestamp,
42    traits::*,
43};
44
45#[doc(inline)]
46#[cfg(feature = "std")]
47pub use self::utils::*;
48
49pub mod epoch;
50pub mod error;
51pub mod timestamp;
52
53#[doc(hidden)]
54pub mod datetime;
55
56#[macro_use]
57pub(crate) mod macros {
58    #[macro_use]
59    pub mod seal;
60}
61
62pub mod traits {
63    //! this moodule implements the core traits supporting the `time` module
64    #[doc(inline)]
65    pub use self::prelude::*;
66
67    mod now;
68    mod raw_timestamp;
69    mod temporal;
70
71    mod prelude {
72        #[doc(inline)]
73        pub use super::now::*;
74        #[doc(inline)]
75        pub use super::raw_timestamp::*;
76        #[doc(hidden)]
77        pub use super::temporal::*;
78    }
79}
80
81pub mod utils {
82    //! time-related utilities
83    //!
84    #[doc(inline)]
85    #[allow(unused_imports)]
86    pub use self::prelude::*;
87
88    #[cfg(feature = "alloc")]
89    mod impl_alloc;
90    #[cfg(feature = "std")]
91    mod impl_std;
92
93    #[allow(unused_imports)]
94    mod prelude {
95        #[cfg(feature = "alloc")]
96        pub use super::impl_alloc::*;
97        #[cfg(feature = "std")]
98        pub use super::impl_std::*;
99    }
100}
101
102#[doc(hidden)]
103pub mod prelude {
104    pub use crate::epoch::Epoch;
105    pub use crate::timestamp::Timestamp;
106    pub use crate::traits::*;
107    #[cfg(feature = "std")]
108    pub use crate::utils::*;
109}