fn timer_periodic(duration: Duration) -> libc::itimerspec { libc::itimerspec { it_value: EPSILON, it_interval: to_timespec(duration), } } fn timer_deadline(duration: Duration) -> libc::itimerspec { libc::itimerspec { it_value: to_timespec(duration), it_interval: ZERO, } } const ZERO: libc::timespec = libc::timespec { tv_sec: 0, tv_nsec: 0, }; const EPSILON: libc::timespec = libc::timespec { tv_sec: 0, tv_nsec: 1, }; fn to_timespec(duration: Duration) -> libc::timespec { let tv_sec = (duration.as_secs() as i64).abs(); let tv_nsec = duration.subsec_nanos() as i64; libc::timespec { tv_sec, tv_nsec } }