pub fn reset(&mut self, dur: Duration, interval: Option<Duration>) -> Result<()> {
        // Safe because we are zero-initializing a struct with only primitive member fields.
        let mut spec: libc::itimerspec = unsafe { mem::zeroed() };
        spec.it_value.tv_sec = dur.as_secs() as libc::time_t;
        // nsec always fits in i32 because subsec_nanos is defined to be less than one billion.
        let nsec = dur.subsec_nanos() as i32;
        spec.it_value.tv_nsec = libc::c_long::from(nsec);

        if let Some(int) = interval {
            spec.it_interval.tv_sec = int.as_secs() as libc::time_t;
            // nsec always fits in i32 because subsec_nanos is defined to be less than one billion.
            let nsec = int.subsec_nanos() as i32;
            spec.it_interval.tv_nsec = libc::c_long::from(nsec);
        }

        // Safe because this doesn't modify any memory and we check the return value.
        let ret = unsafe { timerfd_settime(self.as_raw_fd(), 0, &spec, ptr::null_mut()) };
        if ret < 0 {
            return errno_result();
        }

        Ok(())
    }
/// Sets the timer to expire after `dur`.
///
/// If `interval` is not `None` it represents the period for repeated expirations after the
/// initial expiration. Otherwise the timer will expire just once.  Cancels any existing duration and repeating interval.
Sets the timer to expire after `dur`.
If `interval` is not `None` it represents the period for repeated expirations after the
initial expiration. Otherwise the timer will expire just once.  Cancels any existing duration and repeating interval.
Sets the timer to expire after ` dur ` . If ` interval ` is not ` None ` it represents the period for repeated expirations after the initial expiration . Otherwise the timer will expire just once . Cancels any existing duration and repeating interval .
pub fn reset(&mut self, dur: Duration, interval: Option<Duration>) -> Result<()> {
        // Safe because we are zero-initializing a struct with only primitive member fields.
        let mut spec: libc::itimerspec = unsafe { mem::zeroed() };
        spec.it_value.tv_sec = dur.as_secs() as libc::time_t;
        // nsec always fits in i32 because subsec_nanos is defined to be less than one billion.
        let nsec = dur.subsec_nanos() as i32;
        spec.it_value.tv_nsec = libc::c_long::from(nsec);
        if let Some(int) = interval {
            spec.it_interval.tv_sec = int.as_secs() as libc::time_t;
            // nsec always fits in i32 because subsec_nanos is defined to be less than one billion.
            let nsec = int.subsec_nanos() as i32;
            spec.it_interval.tv_nsec = libc::c_long::from(nsec);
        }
        // Safe because this doesn't modify any memory and we check the return value.
        let ret = unsafe { timerfd_settime(self.as_raw_fd(), 0, &spec, ptr::null_mut()) };
        if ret < 0 {
            return errno_result();
        }
        Ok(())
    }
pub fn reset ( & mut self , dur : Duration , interval : Option < Duration > ) -> Result < ( ) > { // Safe because we are zero-initializing a struct with only primitive member fields. let mut spec : libc :: itimerspec = unsafe { mem :: zeroed ( ) } ; spec . it_value . tv_sec = dur . as_secs ( ) as libc :: time_t ; // nsec always fits in i32 because subsec_nanos is defined to be less than one billion. let nsec = dur . subsec_nanos ( ) as i32 ; spec . it_value . tv_nsec = libc :: c_long :: from ( nsec ) ; if let Some ( int ) = interval { spec . it_interval . tv_sec = int . as_secs ( ) as libc :: time_t ; // nsec always fits in i32 because subsec_nanos is defined to be less than one billion. let nsec = int . subsec_nanos ( ) as i32 ; spec . it_interval . tv_nsec = libc :: c_long :: from ( nsec ) ; } // Safe because this doesn't modify any memory and we check the return value. let ret = unsafe { timerfd_settime ( self . as_raw_fd ( ) , 0 , & spec , ptr :: null_mut ( ) ) } ; if ret < 0 { return errno_result ( ) ; } Ok ( ( ) ) }
Sets the timer to expire after `dur`.
Sets the timer to expire after ` dur ` .
&mut self
dur
Duration
interval
Option<Duration>
&mut self
dur
Duration
interval
Option<Duration>