timer_deque_rs/timer_portable/
mod.rs1pub mod timer;
20
21pub mod poll;
23
24#[cfg(target_os = "linux")]
26pub mod linux;
27
28
29
30#[cfg(any(
32 target_os = "freebsd",
33 target_os = "dragonfly",
34 target_os = "netbsd",
35 target_os = "openbsd",
36 target_os = "macos",
37))]
38pub mod bsd;
39
40#[cfg(target_os = "windows")]
42pub mod windows;
43
44
45pub use timer::
46{
47 TimerFlags,
48 TimerType,
49 TimerSetTimeFlags,
50 TimerReadRes,
51 TimerExpMode,
52 FdTimerCom,
53 AbsoluteTime,
54 RelativeTime,
55};
56
57#[cfg(feature = "enable_mio_compat")]
58pub use timer::TimerFdMioCompat;
59
60pub use poll::{TimerPoll, PollEventType, PolledTimerFd, TimerPollOps};
61pub use timer::{TimerFd, FdTimerMarker};
62
63pub mod portable_error
65{
66 use std::fmt;
67
68 use nix::errno::Errno;
69
70 #[derive(Debug, Clone, PartialEq, Eq)]
72 pub struct TimerPortableErr
73 {
74 last_err: Errno,
76
77 msg: String
79 }
80
81 impl fmt::Display for TimerPortableErr
82 {
83 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
84 {
85 write!(f, "errno: '{}', msg: '{}'", self.last_err, self.msg)
86 }
87 }
88
89 impl TimerPortableErr
90 {
91 pub
92 fn new(last_err: Errno, msg: String) -> Self
93 {
94 return Self{ last_err: last_err, msg: msg };
95 }
96
97 pub
98 fn get_errno(&self) -> Errno
99 {
100 return self.last_err;
101 }
102 }
103
104 pub type TimerPortResult<T> = Result<T, TimerPortableErr>;
106
107
108 #[macro_export]
109 macro_rules! portable_err
110 {
111 ($last_err:expr,$($arg:tt)*) => (
112 return std::result::Result::Err( $crate::timer_portable::portable_error::TimerPortableErr::new($last_err, format!($($arg)*)) )
113 )
114 }
115
116 #[macro_export]
117 macro_rules! map_portable_err
118 {
119 ($last_err:expr,$($arg:tt)*) => (
120 $crate::timer_portable::portable_error::TimerPortableErr::new($last_err, format!($($arg)*))
121 )
122 }
123}