timer_deque_rs/timer_portable/
mod.rs1pub mod timer;
20
21pub mod poll;
23
24#[cfg(target_family = "unix")]
26pub mod unix;
27
28
29#[cfg(target_family = "unix")]
30pub use unix::{timespec, TimerSetTimeFlags, UnixFd, TimerType, TimerFlags};
31
32#[cfg(target_os = "windows")]
34pub mod windows;
35
36#[cfg(target_family = "windows")]
37pub use windows::{timespec, TimerSetTimeFlags, UnixFd, TimerType, TimerFlags};
38
39
40pub use timer::
41{
42 TimerReadRes,
43 TimerExpMode,
44 FdTimerCom,
45 AbsoluteTime,
46 RelativeTime,
47};
48
49#[cfg(all(target_family = "unix", feature = "enable_mio_compat"))]
50pub use timer::TimerFdMioCompat;
51
52pub use poll::{TimerPoll, PollEventType, PolledTimerFd, TimerPollOps};
53pub use timer::{TimerFd, FdTimerMarker, TimerId, AsTimerId};
54
55#[cfg(target_family = "windows")]
56pub mod portable_error
58{
59 use std::fmt;
60
61 use windows::core::Error;
62
63 #[derive(Debug, Clone, PartialEq, Eq)]
65 pub struct TimerPortableErr
66 {
67 last_err: Error,
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: Error, msg: String) -> Self
86 {
87 return Self{ last_err: last_err, msg: msg };
88 }
89
90 pub
91 fn get_errno(&self) -> Error
92 {
93 return self.last_err.clone();
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}
117
118#[cfg(target_family = "unix")]
119pub mod portable_error
121{
122 use std::fmt;
123
124 use nix::errno::Errno;
125
126 #[derive(Debug, Clone, PartialEq, Eq)]
128 pub struct TimerPortableErr
129 {
130 last_err: Errno,
132
133 msg: String
135 }
136
137 impl fmt::Display for TimerPortableErr
138 {
139 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
140 {
141 write!(f, "errno: '{}', msg: '{}'", self.last_err, self.msg)
142 }
143 }
144
145 impl TimerPortableErr
146 {
147 pub
148 fn new(last_err: Errno, msg: String) -> Self
149 {
150 return Self{ last_err: last_err, msg: msg };
151 }
152
153 pub
154 fn get_errno(&self) -> Errno
155 {
156 return self.last_err;
157 }
158 }
159
160 pub type TimerPortResult<T> = Result<T, TimerPortableErr>;
162
163
164 #[macro_export]
165 macro_rules! portable_err
166 {
167 ($last_err:expr,$($arg:tt)*) => (
168 return std::result::Result::Err( $crate::timer_portable::portable_error::TimerPortableErr::new($last_err, format!($($arg)*)) )
169 )
170 }
171
172 #[macro_export]
173 macro_rules! map_portable_err
174 {
175 ($last_err:expr,$($arg:tt)*) => (
176 $crate::timer_portable::portable_error::TimerPortableErr::new($last_err, format!($($arg)*))
177 )
178 }
179}