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
41pub use timer::
42{
43 TimerFlags,
44 TimerType,
45 TimerSetTimeFlags,
46 TimerReadRes,
47 TimerExpMode,
48 FdTimerCom,
49 AbsoluteTime,
50 RelativeTime,
51};
52
53pub use poll::{TimerPoll, PollEventType, PolledTimerFd, TimerPollOps};
54pub use timer::{TimerFd, FdTimerMarker};
55
56pub mod portable_error
58{
59 use std::fmt;
60
61 use nix::errno::Errno;
62
63 #[derive(Debug, Clone, PartialEq, Eq)]
65 pub struct TimerPortableErr
66 {
67 last_err: Errno,
69
70 msg: String
72 }
73
74 impl fmt::Display for TimerPortableErr
75 {
76 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
77 {
78 write!(f, "errno: '{}', msg: '{}'", self.last_err, self.msg)
79 }
80 }
81
82 impl TimerPortableErr
83 {
84 pub
85 fn new(last_err: Errno, msg: String) -> Self
86 {
87 return Self{ last_err: last_err, msg: msg };
88 }
89
90 pub
91 fn get_errno(&self) -> Errno
92 {
93 return self.last_err;
94 }
95 }
96
97 pub type TimerPortResult<T> = Result<T, TimerPortableErr>;
99
100
101 #[macro_export]
102 macro_rules! portable_err
103 {
104 ($last_err:expr,$($arg:tt)*) => (
105 return std::result::Result::Err( $crate::timer_portable::portable_error::TimerPortableErr::new($last_err, format!($($arg)*)) )
106 )
107 }
108
109 #[macro_export]
110 macro_rules! map_portable_err
111 {
112 ($last_err:expr,$($arg:tt)*) => (
113 $crate::timer_portable::portable_error::TimerPortableErr::new($last_err, format!($($arg)*))
114 )
115 }
116}