pzzld_server/
utils.rs

1/*
2    Appellation: utils <module>
3    Contrib: FL03 <jo3mccain@icloud.com>
4*/
5
6///
7#[tracing::instrument(level = "trace", name = "shutdown", target = "platform")]
8pub async fn graceful_shutdown() {
9    tokio::signal::ctrl_c()
10        .await
11        .expect("Failed to gracefully shutdown the platform");
12    tracing::trace!("Signal received; shutting down the platform and related services...");
13}
14
15/// [systime] is a utilitarian function that returns the current system time in milliseconds.
16#[inline]
17pub fn systime() -> u128 {
18    std::time::SystemTime::now()
19        .duration_since(std::time::UNIX_EPOCH)
20        .unwrap()
21        .as_millis()
22}
23
24#[inline]
25pub fn std_time() -> core::time::Duration {
26    std::time::SystemTime::now()
27        .duration_since(std::time::UNIX_EPOCH)
28        .unwrap()
29}
30
31pub fn timestamp() -> i64 {
32    chrono::Local::now().timestamp()
33}