timer_deque_rs/common.rs
1/*-
2 * timer-rs - a Rust crate which provides timer and timer queues based on target OS
3 * functionality.
4 *
5 * Copyright (C) 2025 Aleksandr Morozov
6 *
7 * The timer-rs crate can be redistributed and/or modified
8 * under the terms of either of the following licenses:
9 *
10 * 1. the Mozilla Public License Version 2.0 (the “MPL”) OR
11 *
12 * 2. EUROPEAN UNION PUBLIC LICENCE v. 1.2 EUPL © the European Union 2007, 2016
13 */
14
15use std::fmt;
16
17use chrono::{DateTime, Local};
18
19
20/// Returns the current [DateTime].
21pub
22fn get_current_timestamp() -> DateTime<Local>
23{
24 return chrono::offset::Local::now();
25}
26
27/// A default struct which is provided when the timer queue does not
28/// require any input.
29#[derive(Debug, Clone, Copy, Eq, PartialEq)]
30pub struct NoTarget;
31
32impl fmt::Display for NoTarget
33{
34 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
35 {
36 write!(f, "no_target")
37 }
38}
39
40/// A default struct which is returned when the timer queue does
41/// issue any identification of the instance in queue.
42#[derive(Debug, Clone, Copy, Eq, PartialEq)]
43pub struct NoTicket;
44
45impl fmt::Display for NoTicket
46{
47 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
48 {
49 write!(f, "no_ticket")
50 }
51}