pub mod timer;
pub mod poll;
#[cfg(target_family = "unix")]
pub mod unix;
#[cfg(target_family = "unix")]
pub use unix::{timespec, TimerSetTimeFlags, UnixFd, TimerType, TimerFlags};
#[cfg(target_os = "windows")]
pub mod windows;
#[cfg(target_family = "windows")]
pub use windows::{timespec, TimerSetTimeFlags, UnixFd, TimerType, TimerFlags};
pub use timer::
{
TimerReadRes,
TimerExpMode,
FdTimerCom,
AbsoluteTime,
RelativeTime,
};
#[cfg(all(target_family = "unix", feature = "enable_mio_compat"))]
pub use timer::TimerFdMioCompat;
pub use poll::{TimerPoll, PollEventType, PolledTimerFd, TimerPollOps};
pub use timer::{TimerFd, FdTimerMarker, TimerId, AsTimerId};
#[cfg(target_family = "windows")]
pub mod portable_error
{
use std::fmt;
use windows::core::Error;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct TimerPortableErr
{
last_err: Error,
msg: String
}
impl fmt::Display for TimerPortableErr
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
{
write!(f, "errno: '{}', msg: '{}'", self.last_err, self.msg)
}
}
impl TimerPortableErr
{
pub
fn new(last_err: Error, msg: String) -> Self
{
return Self{ last_err: last_err, msg: msg };
}
pub
fn get_errno(&self) -> Error
{
return self.last_err.clone();
}
}
pub type TimerPortResult<T> = Result<T, TimerPortableErr>;
#[macro_export]
macro_rules! portable_err
{
($last_err:expr,$($arg:tt)*) => (
return std::result::Result::Err( $crate::timer_portable::portable_error::TimerPortableErr::new($last_err, format!($($arg)*)) )
)
}
#[macro_export]
macro_rules! map_portable_err
{
($last_err:expr,$($arg:tt)*) => (
$crate::timer_portable::portable_error::TimerPortableErr::new($last_err, format!($($arg)*))
)
}
}
#[cfg(target_family = "unix")]
pub mod portable_error
{
use std::fmt;
use nix::errno::Errno;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct TimerPortableErr
{
last_err: Errno,
msg: String
}
impl fmt::Display for TimerPortableErr
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
{
write!(f, "errno: '{}', msg: '{}'", self.last_err, self.msg)
}
}
impl TimerPortableErr
{
pub
fn new(last_err: Errno, msg: String) -> Self
{
return Self{ last_err: last_err, msg: msg };
}
pub
fn get_errno(&self) -> Errno
{
return self.last_err;
}
}
pub type TimerPortResult<T> = Result<T, TimerPortableErr>;
#[macro_export]
macro_rules! portable_err
{
($last_err:expr,$($arg:tt)*) => (
return std::result::Result::Err( $crate::timer_portable::portable_error::TimerPortableErr::new($last_err, format!($($arg)*)) )
)
}
#[macro_export]
macro_rules! map_portable_err
{
($last_err:expr,$($arg:tt)*) => (
$crate::timer_portable::portable_error::TimerPortableErr::new($last_err, format!($($arg)*))
)
}
}